Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 7th, 2005, 08:11 AM
Registered User
 
Join Date: Jun 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT Looks right, but no output

XML - Multiple Address response:

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://www.esriuk.com/gazops">
    <GAZOPS_DATA_REQUEST operation="ADDRESS_MATCH">
        <OPERATION_RESULT>success</OPERATION_RESULT>
        <PICK_LIST>
            <PICK_LIST_TYPE>Properties</PICK_LIST_TYPE>
            <FIELD_DEFINTION>
                <NAME>% Match</NAME>
                <FIELD_WIDTH>10</FIELD_WIDTH>
            </FIELD_DEFINTION>
            <FIELD_DEFINTION>
                <NAME>Value</NAME>
                <FIELD_WIDTH>500</FIELD_WIDTH>
            </FIELD_DEFINTION>
            <PICK_LIST_ENTRY id="0">
                <MATCH_COUNT>1</MATCH_COUNT>
                <CRITERIA_FIELD>GAZOPS_UNIQUE_ID</CRITERIA_FIELD>
                <IDENTITY>UPRN000000274739</IDENTITY>
                <SCORE>100</SCORE>
                <DESCRIPTION>Bcc Car Park Adjacent To, Mauretania, St Georges Road, Bristol, BS1 5UY,</DESCRIPTION>
                <FINAL>True</FINAL>
            </PICK_LIST_ENTRY>
            <PICK_LIST_ENTRY id="1">
                <MATCH_COUNT>1</MATCH_COUNT>
                <CRITERIA_FIELD>GAZOPS_UNIQUE_ID</CRITERIA_FIELD>
                <IDENTITY>UPRN000000106560</IDENTITY>
                <SCORE>100</SCORE>
                <DESCRIPTION>Brunel House, St Georges Road, Bristol, BS1 5UY,</DESCRIPTION>
                <FINAL>True</FINAL>
            </PICK_LIST_ENTRY>
            <PICK_LIST_ENTRY id="2">
                <MATCH_COUNT>1</MATCH_COUNT>
                <CRITERIA_FIELD>GAZOPS_UNIQUE_ID</CRITERIA_FIELD>
                <IDENTITY>UPRN000000274740</IDENTITY>
                <SCORE>100</SCORE>
                <DESCRIPTION>Mauretania, St Georges Road, Bristol, BS1 5UY,</DESCRIPTION>
                <FINAL>True</FINAL>
            </PICK_LIST_ENTRY>
        </PICK_LIST>
        <CACHE_ID>GZ2</CACHE_ID>
    </GAZOPS_DATA_REQUEST>
</string>

XML - Single Address Response:

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://www.esriuk.com/gazops">
    <GAZOPS_DATA_REQUEST operation="ADDRESS_MATCH">
        <OPERATION_RESULT>success</OPERATION_RESULT>
        <CACHE_ID>GZ3</CACHE_ID>
        <ADDRESS_MATCH>
            <F>
                <N>GAZOPS_FORMATTED_ADDRESS</N>
                <V tp="xml">
                    <ADDLINE>Brunel House</ADDLINE>
                    <ADDLINE>St Georges Road</ADDLINE>
                    <ADDLINE>Bristol</ADDLINE>
                    <ADDLINE>BS1 5UY</ADDLINE>
                    <ADDLINE/>
                </V>
            </F>
            <F>
                <N>GAZOPS_UNIQUE_ID</N>
                <V>UPRN000000106560</V>
            </F>
            <F>
                <N>GAZOPS_SCORE</N>
                <V>100</V>
            </F>
            <F>
                <N>UPRN</N>
                <V>000000106560</V>
            </F>
            <F>
                <N>PAO_DESC</N>
                <V>Brunel House</V>
            </F>
            <F>
                <N>SAO_DESC</N>
                <V/>
            </F>
            <F>
                <N>STREET_NAME</N>
                <V>St Georges Road</V>
            </F>
            <F>
                <N>TOWN_NAME</N>
                <V>Bristol</V>
            </F>
            <F>
                <N>LOCALITY_NAME</N>
                <V>City Centre</V>
            </F>
            <F>
                <N>COUNTY_NAME</N>
                <V/>
            </F>
            <F>
                <N>POSTCODE</N>
                <V>BS1 5UY</V>
            </F>
            <F>
                <N>PO_BOX</N>
                <V/>
            </F>
            <F>
                <N>DEPARTMENT</N>
                <V/>
            </F>
            <F>
                <N>ORGANISATION</N>
                <V/>
            </F>
            <F>
                <N>POST_TOWN</N>
                <V/>
            </F>
            <F>
                <N>ST_KEYVAL</N>
                <V>0000C2DNSD000</V>
            </F>
            <F>
                <N>LPI_ID</N>
                <V>001BEPDNLI000</V>
            </F>
            <F>
                <N>LPI_ADDRESS</N>
                <V>Brunel House
St Georges Road
Bristol
BS1 5UY</V>
            </F>
            <F>
                <N>LPI_LOGICAL_STATUS</N>
                <V>1</V>
            </F>
            <F>
                <N>GAZOPS_EASTING</N>
                <V>358206</V>
            </F>
            <F>
                <N>GAZOPS_NORTHING</N>
                <V>172828</V>
            </F>
            <F>
                <N>GAZOPS_ALIAS_ID</N>
                <V>001BEPDNLI000</V>
            </F>
        </ADDRESS_MATCH>
    </GAZOPS_DATA_REQUEST>
</string>



XSLT:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <xsl:choose>
            <xsl:when test="//OPERATION_RESULT='No Match Found'">
                <xsl:choose>
                    <xsl:when test="count(//GAZOPS_VAGUE)&gt;0">
                        <response>Query is too vague. Please refine or change the query.<count>0</count>
                            <addresses/>
                        </response>
                    </xsl:when>
                    <xsl:otherwise>
                        <response>No Match Found. Please refine the query<count>0</count>
                            <addresses/>
                        </response>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            <xsl:when test="count(//ADDRESS_MATCH)=1">
                <response>Exact match found.
                    <addresses>
                        <address>
                            <xsl:for-each select="//F[N='GAZOPS_FORMATTED_ADDRESS']/V/ADDLINE">
                                <xsl:value-of select="."/>
                            </xsl:for-each>
                        </address>
                    </addresses>
                </response>
            </xsl:when>
            <xsl:otherwise>
                <response>
                    <addresses>
                        <xsl:for-each select="//PICK_LIST_ENTRY">
                            <address>
                                <xsl:value-of select="DESCRIPTION"/>
                            </address>
                        </xsl:for-each>
                    </addresses>
                </response>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>

OUTPUT Zilch, nada, nothing

Any ideas?
  #2 (permalink)  
Old June 9th, 2005, 08:47 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Because of this:

<string xmlns="http://www.esriuk.com/gazops">

all your elements are in a namespace, and your path expressions need to use a prefix that's bound to this namespace. Declare

xmlns:p="http://www.esriuk.com/gazops"

in the xsl:stylesheet element, and replace expressions such as

test="//OPERATION_RESULT='No Match Found'"

with

test="//p:OPERATION_RESULT='No Match Found'"



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT to get hyperlinks in output ashv XSLT 2 December 7th, 2008 06:14 AM
changing output for one node in XSLT shane_carty XSLT 3 February 27th, 2008 05:28 AM
xslt output: empty rectangle character pcase XSLT 1 December 3rd, 2007 07:39 PM
XSLT with output very similar to input sindrit XSLT 2 July 30th, 2007 08:38 AM
XSLT output with tags trinkets XSLT 22 November 14th, 2006 11:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.