Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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
 
Old July 21st, 2008, 06:36 AM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default Vacation Address

I am trying to select a vacation (use="HV") home address when there are two addresses present. I am only able to get the first address and can not select the address based off the "use". Thank you for any help!


XSLT Version 2.0

<xsl:if test="/n1:ClinicalDocument/n1:documentationOf/n1:serviceEvent/n1:performer/n1:assignedEntity[n1:addr/@use='HV']">
    <td width='50%' align='left' valign="top">
    <xsl:call-template name="getAddress">
    <xsl:with-param name="addr" select="./n1:assignedEntity/n1:addr"/>
    </xsl:call-template>

    <xsl:call-template name="getTelecom">
    <xsl:with-param name="telecom" select="./n1:assignedEntity/n1:telecom"/>
    </xsl:call-template>
    </td>
    </xsl:if>


XML Code

    <addr use="HP">
        <streetAddressLine>9876 Flagler Drive</streetAddressLine>
        <city>Gaithersburg</city>
        <state>MD</state>
        <postalCode>20878</postalCode>
      </addr>

      <addr use="HV">
        <streetAddressLine>61 Tropica Lane</streetAddressLine>
        <city>Key West</city>
        <state>FL</state>
        <postalCode>33040</postalCode>
      </addr>

      <telecom use="HP" value="tel:+1-301-555-9771" />

      <telecom use="WP" value="tel:+1-301-555-9800" />

      <telecom value="mailto:[email protected]" />

 
Old July 21st, 2008, 06:40 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Your problem is that you are selecting the 'assignedEntity' which 'has' an address with @use = 'HV', but then when you supply the template with the current 'assignedEntity' address you just pass in the first one.

    <xsl:call-template name="getAddress">
    <xsl:with-param name="addr" select="./n1:assignedEntity/n1:addr[@use='HV']"/>
    </xsl:call-template>

    <xsl:call-template name="getTelecom">
    <xsl:with-param name="telecom" select="./n1:assignedEntity/n1:telecom[@use='HV']"/>
    </xsl:call-template>


/- Sam Judson : Wrox Technical Editor -/
 
Old July 21st, 2008, 07:46 AM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Correct, however still unable to pull just the address with the use of "HV". I have attached the corrected code. Thanks again for your help.

<xsl:for-each select="/n1:ClinicalDocument/n1:documentationOf/n1:serviceEvent/n1:performer">


    <tr>
    <td width='50%' align='left' valign="top">
    <xsl:if test="./n1:assignedEntity[n1:addr/@use='WP']">
    <xsl:call-template name="getAddress">
    <xsl:with-param name="addr" select="./n1:assignedEntity/n1:addr"/>
    </xsl:call-template>
    </xsl:if>


    <xsl:if test="./n1:assignedEntity[n1:telecom/@use='WP']">
    <xsl:call-template name="getTelecom">
    <xsl:with-param name="telecom" select="./n1:assignedEntity/n1:telecom"/>
    </xsl:call-template>
    </xsl:if>
    </td>


    <td width='50%' align='left' valign="top">
    <xsl:if test="./n1:assignedEntity[n1:addr/@use='HV']">
    <xsl:call-template name="getAddress">
    <xsl:with-param name="addr" select="./n1:assignedEntity/n1:addr"/>
    </xsl:call-template>
    </xsl:if>


    <xsl:if test="./n1:assignedEntity[n1:telecom/@use='HV']">
    <xsl:call-template name="getTelecom">
    <xsl:with-param name="telecom" select="./n1:assignedEntity/n1:telecom"/>
    </xsl:call-template>
    </xsl:if>
    </td>
    </tr>
</xsl:for-each>

 
Old July 21st, 2008, 08:15 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You haven't changed the <xsl:with-param> code, therefore you obviously didn't understand my previous answer.

Please try reading my code more slowly, looking at the differences between your code and mine, and see if you understand what I have changed (and why).

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Address use="HP" Navy1991_1 XSLT 1 July 2nd, 2008 02:40 PM
Help me i must Get IP Address pla_2 C# 2005 2 October 12th, 2006 07:51 AM
how to get the value at the address?? keepsmiling_sruti VB How-To 3 July 8th, 2005 01:15 PM
Retreiving IP address & gateway address sjangit VBScript 0 February 3rd, 2004 02:02 PM





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