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 6th, 2008, 03:25 PM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default finding a unique attribute

XSLT 2.0

Is there a better way to try and find a unique attribute in a very large XML document? My unique attribute is an HL7 OID of 2.16.840.1.113883.10.20.1.12. The XSLT is not allowing me to identify the OID and then render all element under the OID and nothing else. There are several componet and section elements with the only unique identifier being the OID seperating the different sections. To parse the sections out and capture only the elements needed I am attempting to use a IF statement of:

<xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section/n1:entry/n1:procedure">
     <xsl:sort select="./n1:component/n1:section/n1:entry/n1:procedure/n1:effectiveTime/n1:low/@value" order="descending"/>
    <xsl:if test="//n1:templateId[@root='2.16.840.1.113883.10.20.1.12']">

    <tr>

    <td width='10%' align='left' valign="top">
    <xsl:call-template name="formatDate">
    <xsl:with-param name="date" select="./n1:effectiveTime/n1:low/@value"/>
    </xsl:call-template></td>


    <td width='30%' align='left' valign="top"><xsl:value-of select="./n1:code/@displayName"/></td>
    </tr>

    </xsl:if>
    </xsl:for-each>
    </table>


XML CODE

<component>
        <section>
         <templateId root="2.16.840.1.113883.10.20.1.12" />
        
         <code code="47519-4" displayName="History of procedures" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" />
         <title>Procedures</title>
         <text></text>
         <entry typeCode="DRIV">
            <procedure classCode="PROC" moodCode="EVN">
            
             <templateId root="2.16.840.1.113883.10.20.1.29" />
             <id root="e401f340-7be2-11db-9fe1-0800200c9a66" />
            
             <code code="71861002" displayName="Implantation" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT">
<originalText>
                 <reference value="#proc-1" />
</originalText>
</code>
</section>
</component>
 
Old July 6th, 2008, 06:07 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your code

<xsl:if test="//n1:templateId[@root='2.16.840.1.113883.10.20.1.12']">

says "if there is a templateId with this value of @root somewhere in the document, then do this processing, otherwise do nothing." This has little resemblance to your English-language statement of the problem "render all element under the OID and nothing else".

I'm guessing wildly, but I suspect you might want

<xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section[n1:templateId/@root='2.16.840.1.113883.10.20.1.12']/n1:entry/n1:procedure">

Though I suspect that's still not quite right - the sort key doesn't bear much relationship to your input, and I don't see where n1:effectiveTime is supposed to come from.

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
Replace an attribute with another attribute georgemeng XSLT 8 June 10th, 2008 11:04 AM
unique attribute names for form elements fishmonkey XSLT 3 March 16th, 2008 07:46 PM
Selecting unique value of an attribute and render vinaura XSLT 4 December 18th, 2006 04:35 PM
Unique Problem rekha_jsr Classic ASP Basics 0 December 10th, 2005 12:21 AM
Access to attribute values from class of attribute jacob C# 1 October 28th, 2005 01:11 PM





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