Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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?
Reply With Quote
  #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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:13 PM.


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