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 June 4th, 2008, 11:53 AM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default for-each looping - mystery comma return

Unable to figure out why I am getting a comma in the first returned row of the "for-each" loop. All attributes are showing correctly - just first row is incorrect.

XSLT Document
<xsl:stylesheet version="2.0"
<xsl:for-each select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section/n1:entry/n1:substanceAdministration">
<xsl:sort select="./n1:entryRelationship/n1:supply/n1:author/n1:time/@value"/>
<xsl:if test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section/n1:templateId/@root='2.16.840.1.113883.10.20.1.8'">

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

    <td width='10%' align='left' valign="top">
    <xsl:value-of select="./n1:entryRelationship/n1:supply/n1:author/n1:assignedAuthor/n1:assignedPerson/n1:name"/>
    </td>

    <td width='30%' align='left' valign="top">
    <xsl:value-of select="./n1:consumable/n1:manufacturedProduct/n1:manufacturedMaterial/n1:name"/>
    </td>

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

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

    <td width='10%' align='left' valign="top">
    <xsl:value-of select="./n1:doseQuantity/@value"/>
    </td>

    <td width='10%' align='left' valign="top">
    <xsl:value-of select="./n1:effectiveTime/n1:period/@value"/>
    <xsl:value-of select="./n1:effectiveTime/n1:period/@unit"/>
    </td>

    <td width='10%' align='left' valign="top">
    <xsl:value-of select="./n1:maxDoseQuantity/n1:numerator/@value"/>
    </td>
    </tr>
</xsl:if>
</xsl:for-each>

XML Document

<component>
        <section>
          <templateId root="2.16.840.1.113883.10.20.1.8" />

          <code code="10160-0" displayName="History of medication use" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" />
          <title>Medication</title>
          <text></text>

          <entry typeCode="DRIV">
            <substanceAdministration classCode="SBADM" moodCode="EVN">

              <templateId root="2.16.840.1.113883.10.20.1.24" />
              <templateId root="2.16.840.1.113883.3.88.11.32.8" />
              <id root="cdbd5b05-6cde-11db-9fe1-0800200c9a66" />
              <text>
                <reference value="#sig-1" />
              </text>
              <statusCode code="completed" />

              <effectiveTime xsi:type="IVL_TS" nullFlavor="UNK" />

              <effectiveTime xsi:type="PIVL_TS" institutionSpecified="true" operator="A">
                <period value="24" unit="h" />
              </effectiveTime>

              <routeCode code="C38288" displayName="Oral" codeSystem="2.16.840.1.113883.3.26.1.1" codeSystemName="NCI Thesaurus" />

              <approachSiteCode code="49596003" displayName="Digestive organ structure" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT" />

              <doseQuantity value="1" unit="{TABLET}" />

              <maxDoseQuantity xsi:type="RTO_PQ_PQ">
                <numerator value="50" />
                <denominator value="1" />
              </maxDoseQuantity>

              <administrationUnitCode code="C42998" displayName="TABLET" codeSystem="2.16.840.1.113883.3.26.1.1" codeSystemName="NCI Thesaurus" />

              <consumable>
                <manufacturedProduct classCode="MANU">

                  <templateId root="2.16.840.1.113883.10.20.1.53" />
                  <templateId root="2.16.840.1.113883.3.88.11.32.9" />
                  <manufacturedMaterial classCode="MMAT">
                    <code code="311810" displayName="Multivitamin oral tablet" codeSystem="2.16.840.1.113883.6.88" codeSystemName="RxNorm">
                      <translation code="PLACE_HOLDER" displayName="PLACE_HOLDER" codeSystem="2.16.840.1.113883.6.88" codeSystemName="PLACE_HOLDER" />
                    </code>
                    <name>Centrum silver tab (multiple vitamins-minerals)</name>
                  </manufacturedMaterial>
                  <manufacturerOrganization>
                    <name>Johnson &amp; Johnson</name>
                  </manufacturerOrganization>
                </manufacturedProduct>
              </consumable>

              <entryRelationship typeCode="SUBJ">
                <observation classCode="OBS" moodCode="EVN">

                  <templateId root="2.16.840.113883.3.88.11.32.10" />
                  <code code="329505003" displayName="Over the counter products" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT" />
                  <statusCode code="completed" />
                </observation>
              </entryRelationship>

              <entryRelationship typeCode="REFR">
                <observation classCode="OBS" moodCode="EVN">
                  <code code="33999-4" displayName="Status" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" />
                  <statusCode code="completed" />

                  <value xsi:type="CE" code="55561003" displayName="Active" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT" />
                </observation>
              </entryRelationship>

              <entryRelationship typeCode="RSON">
                <observation classCode="OBS" moodCode="EVN">
                  <templateId root="2.16.840.1.113883.10.20.1.28"></templateId>
                  <code code="47903000" displayName="Vitamin B Deficiency " codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT" />
                  <text>
                    <reference value="#indication-1" />
                  </text>
                  <statusCode code="completed" />
                  <effectiveTime />
                </observation>
              </entryRelationship>

              <entryRelationship typeCode="SUBJ" inversionInd="true">
                <act classCode="ACT" moodCode="INT">
                  <templateId root="2.16.840.1.113883.10.20.1.49" />
                  <code />
                  <text>
                    <reference value="#patient-instruction" />
                  </text>
                  <statusCode code="completed" />
                </act>
              </entryRelationship>

              <entryRelationship typeCode="CAUS">
                <observation classCode="OBS" moodCode="EVN">
                  <templateId root="2.16.840.1.113883.10.20.1.54" />
                  <code />
                  <text>
                    <reference value="#reaction" />
                  </text>
                  <statusCode code="completed" />
                </observation>
              </entryRelationship>

              <entryRelationship typeCode="REFR">
                <supply classCode="SPLY" moodCode="INT">

                  <templateId root="2.16.840.1.113883.3.88.1.11.32.11" />

                  <id root="14ED7742-2428-4e2c-9446-A9B0D0075272" extension="20097864565331453252"></id>

                  <effectiveTime value="20100801"></effectiveTime>

                  <repeatNumber value="5" />

                  <quantity value="90" />

                  <author>

                    <time value="20080604" />
                    <assignedAuthor>
                      <id root="2.16.840.1.113883.4.6.1013905751" extension="Provider ID" />
                      <assignedPerson>
                        <name>
                          <prefix>Dr.</prefix>
                          <given>Steven</given>
                          <given>R</given>
                          <family>Flier</family>
                        </name>
                      </assignedPerson>
                    </assignedAuthor>
                  </author>

                  <entryRelationship typeCode="SUBJ" inversionInd="true">
                    <act classCode="ACT" moodCode="INT">

                      <templateId root="2.16.840.1.113883.10.20.1.43" />
                      <code />
                      <text>
                        <reference value="#fulfillment-instruction1" />
                      </text>
                    </act>
                  </entryRelationship>
                </supply>
              </entryRelationship>

              <precondition>
                <criterion />
              </precondition>

              <participant typeCode="CSM">
                <participantRole classCode="MANU">
                  <code code="412307009" displayName="drug vehichle" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT"></code>
                  <playingEntity classCode="MMAT">
                    <code />
                    <name />
                  </playingEntity>
                </participantRole>
              </participant>
            </substanceAdministration>
          </entry>
          <entry typeCode="DRIV">
            <substanceAdministration classCode="SBADM" moodCode="INT">

              <templateId root="2.16.840.1.113883.10.20.1.24" />
              <templateId root="2.16.840.1.113883.3.88.11.32.8" />
              <id root="a2738a02-006c-4812-a14d-87a6421ccc24" />
              <text>
                <reference value="#sig-2" />
              </text>
              <statusCode code="completed" />

              <effectiveTime xsi:type="IVL_TS">
                <low value="200710" />
              </effectiveTime>

              <effectiveTime xsi:type="PIVL_TS" institutionSpecified="true" operator="A">
                <period value="24" unit="h" />
              </effectiveTime>

              <routeCode code="C38288" displayName="Oral" codeSystem="2.16.840.1.113883.3.26.1.1" codeSystemName="NCI Thesaurus" />

              <approachSiteCode code="49596003" displayName="Digestive organ structure" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT"></approachSiteCode>

              <doseQuantity value="1" unit="{TABLET}" />

              <maxDoseQuantity>
                <numerator value="20" />
                <denominator value="1" />
              </maxDoseQuantity>

              <administrationUnitCode code="C42998" displayName="TABLET" codeSystem="2.16.840.1.113883.3.26.1.1" codeSystemName="NCI Thesaurus"></administrationUnitCode>

              <consumable>
                <manufacturedProduct classCode="MANU">

                  <templateId root="2.16.840.1.113883.10.20.1.53" />
                  <templateId root="2.16.840.1.113883.3.88.11.32.9" />

                  <manufacturedMaterial>
                    <code code="371481" displayName="Cholecalciferol Oral Tablet" codeSystem="2.16.840.1.113883.6.88" codeSystemName="RxNorm">
                      <originalText>Cholecalciferol</originalText>
                    </code>
                    <name>Vitamin D3 (cholecalciferol)</name>
                  </manufacturedMaterial>
                  <manufacturerOrganization>
                    <name>Nexcare</name>
                  </manufacturerOrganization>
                </manufacturedProduct>
              </consumable>

              <entryRelationship typeCode="SUBJ">
                <observation classCode="OBS" moodCode="EVN">
                  <templateId root="2.16.840.113883.3.88.11.32.10" />
                  <code code="73639000" displayName="Prescription Drug" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT" />
                  <statusCode code="completed" />
                </observation>
              </entryRelationship>

              <entryRelationship typeCode="REFR">
                <observation classCode="OBS" moodCode="EVN">
                  <code code="33999-4" displayName="Status" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" />
                  <statusCode code="completed" />

                  <value xsi:type="CE" code="55561003" displayName="Active" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT" />
                </observation>
              </entryRelationship>

              <entryRelationship typeCode="RSON">
                <observation classCode="OBS" moodCode="EVN">
                  <templateId root="2.16.840.1.113883.10.20.1.28" />
                  <code code="34713006" displayName="Vitamin D Deficiency " codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT" />
                  <text>
                    <reference value="#indication-2" />
                  </text>
                  <statusCode code="completed" />
                  <effectiveTime />
                </observation>
              </entryRelationship>

              <entryRelationship typeCode="SUBJ" inversionInd="true">
                <act classCode="ACT" moodCode="INT">
                  <templateId root="2.16.840.1.113883.10.20.1.49" />
                  <code />
                  <text>
                    <reference value="#patient-instruction" />
                  </text>
                </act>
              </entryRelationship>

              <entryRelationship typeCode="CAUS">
                <observation classCode="OBS" moodCode="EVN">
                  <templateId root="2.16.840.1.113883.10.20.1.54" />
                  <code />
                  <text>
                    <reference value="#reaction" />
                  </text>
                  <statusCode code="completed" />
                </observation>
              </entryRelationship>

              <entryRelationship typeCode="REFR">

                <supply classCode="SPLY" moodCode="INT">

                  <templateId root="2.16.840.1.113883.3.88.1.11.32.11" />

                  <id root="14ED7742-2428-4e2c-9446-A9B0D0075272" extension="SCRIP#"></id>

                  <effectiveTime value="20090801"></effectiveTime>

                  <repeatNumber value="3" />

                  <quantity value="30" />

                  <author>

                    <time value="20080501" />
                    <assignedAuthor>
                      <id root="2.16.840.1.113883.4.6.1013905751" extension="Provider ID" />
                      <assignedPerson>
                        <name>
                          <prefix>Dr.</prefix>
                          <given>Steven</given>
                          <given>R</given>
                          <family>Flier</family>
                        </name>
                      </assignedPerson>
                    </assignedAuthor>
                  </author>

                  <entryRelationship typeCode="SUBJ" inversionInd="true">
                    <act classCode="ACT" moodCode="INT">

                      <templateId root="2.16.840.1.113883.10.20.1.43" />
                      <code />
                      <text>
                        <reference value="#fulfillment-instruction1" />
                      </text>
                    </act>
                  </entryRelationship>
                </supply>
              </entryRelationship>

              <entryRelationship typeCode="REFR">
                <supply classCode="SPLY" moodCode="EVN">
                  <id root="14ED7742-2428-4e2c-9446-A9B0D0075272" extension="SCRIP#" />

                  <statusCode code="completed" />

                  <effectiveTime value="20080501"></effectiveTime>

                  <quantity value="30" unit="{TABLET}" />

                  <performer>
                    <assignedEntity>

                      <id root="2.16.840.1.113883.4.6.1013905751" />
                      <addr use="WP">
                        <streetAddressLine>555 Xavier Ave</streetAddressLine>
                        <streetAddressLine />
                        <city>Baltimore </city>
                        <state>MD</state>
                        <postalCode>20224</postalCode>
                      </addr>
                      <assignedPerson>
                        <name>
                          <prefix>Dr.</prefix>
                          <given>Steven</given>
                          <given>R</given>
                          <family>Flier</family>
                        </name>
                      </assignedPerson>
                      <representedOrganization>

                        <id root="2.16.840.1.113883.4.6.1942405782" />
                        <name>Personal Physicians HealthCare</name>
                      </representedOrganization>
                    </assignedEntity>
                  </performer>

                  <entryRelationship typeCode="COMP">
                    <sequenceNumber value="4" />
                  </entryRelationship>
                </supply>
              </entryRelationship>

              <precondition>
                <criterion />
              </precondition>

              <participant typeCode="CSM">
                <participantRole classCode="MANU">
                  <code code="412307009" displayName="drug vehichle" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT"></code>
                  <playingEntity classCode="MMAT">
                    <code />
                    <name />
                  </playingEntity>
                </participantRole>
              </participant>
            </substanceAdministration>
          </entry>
        </section>
      </component>

 
Old June 4th, 2008, 12:03 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It's very odd to have this test inside the loop, since its value doesn't depend on anything in the loop: I wonder if this is what you really intended?

<xsl:if test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section/n1:templateId/@root='2.16.840.1.113883.10.20.1.8'">

I can't see any reason for an extraneous comma (but there's way too much detail here for me to study). Are you looking at the HTML output as source, or as displayed in the browser? If you generate badly structured HTML tables, browsers can sometimes display text in very peculiar places.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 4th, 2008, 12:33 PM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is the short version:D of the document. There are several component sections to the document, so I had to put an IF statement with the templateId to single out this specific segment. I am looking at the information in a browser. I appreciate your feedback and time!

 
Old June 4th, 2008, 01:42 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>I am looking at the information in a browser.

I would recommend looking at the source HTML. Find the stray comma in there, and you'll have a much better clue what part of your stylesheet produced it.

Even better, use a tool like Stylus Studio which does "backmapping" - you can point to any part of your output, and it will tell you where in the stylesheet (and where in the source document) it came from.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 5th, 2008, 01:33 PM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm thinking that this maybe happening because the XSLT can't understand the @root='2.16.840.1.113883.10.20.1.11' section in the code.

code
<xsl:if test="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section/n1:templateId[@root='2.16.840.1.113883.10.20.1.11']">



 
Old June 5th, 2008, 01:37 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>I'm thinking that this maybe happening because the XSLT can't understand the @root='2.16.840.1.113883.10.20.1.11' section in the code.

That's a perfectly ordinary XPath predicate and I can't see any reason why it should cause problems of any kind, let along causing an unwanted comma in the output.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 5th, 2008, 01:52 PM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah, still getting one crazy comma at the top of the list. I am trying to go through the code line-by-line. Let you know if I figure it out.

Thanks!






Similar Threads
Thread Thread Starter Forum Replies Last Post
String Mystery binishkhan87 C# 3 October 6th, 2007 04:19 PM
error mystery htummala Oracle 2 February 28th, 2005 02:28 AM
MM:DataSet mystery bridon123 Dreamweaver (all versions) 2 January 12th, 2004 10:44 PM
looping through return records in sproc jtyson SQL Server ASP 5 July 14th, 2003 10:16 AM





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