Subject: Re: Sorting attributes with XSL - Is there a way to "grep" and match on partial attribute string value? From: Bill Martschenko <billmartschenko@xxxxxxxxx> Date: Wed, 29 Sep 1999 02:19:41 -0700 (PDT) |
Here is an IE5 solution. 3 mods to your original XSL as follows. 1) Add a language attrib to your xsl:stylesheet as follows. <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" language="VBScript"> 2) Replace the placeholder as follows. <xsl:for-each select="HL7A1/MSH" order-by= "+PID/@Name"> <xsl:if expr="StartsWithD(me)"> <xsl:apply-templates /> <br/><br/> </xsl:if> </xsl:for-each> Of course, you could make the StartsWithD function anything you like. I'll stick to your original "D or d" request. The "placeholder" is what you have between the <BODY> </BODY> tags in your original XSL. 3) Insert the following anywhere between <xsl:template> declarations or just before </xsl:stylesheet>. <xsl:script> function StartsWithD(mshNode) name = mshNode.selectSingleNode("PID/@Name").text StartsWithD = left(name,1) = "D" or left(name,1) = "d" end function </xsl:script> Bill > From: XSL Mailing List <xsl@xxxxxxxxxxxxxxxxxxx> > Date: 22 Sep 1999 15:21:20 -0700 > Cc: hcasteel@xxxxxxxxxxxxxxxxxxx > > I want to match attribute string value for HL71A/MSH/PID/@Name NOT as exact match as follows: > > <xsl:apply-templates select="HL7A1/MSH/PID[@Name = 'Donneley^Floyd']" order-by = "+@Name" /> > > Instead, what I want to do is sort @Name and match for all @Name attribute values where @Name starts with D or d (or any other letter) and would retrieve all attribute values which start with D or and then populate the table. > > Any suggestions?? HELP!! > > > > I have the following XML file: (XSL file below the XML) > > <?xml version="1.0"?> > <?xml-stylesheet type="text/xsl" href="19990917_Batch_File_XML_HL7_mod_20_Donneley^Floyd.xsl"?> > <HL7A1> > <MSH Origin='labtstn' Dest='cabtstn' TStamp='93000000' Type='ORU' > Id='57922001'> > <PID Id='22392248' ExtId='111222333' Name='Smith^Jane' > DOB='19170615' Sex='F'> > <OBR Id='22392248' PlacerId='222333444-1' TStamps='9300001'> > <USID Id='7010'>COMPLETE BLOOD COUNT</USID> > <OBX TStamp='9300001'> > <USID Id='5101'>REMARKS</USID> > <OBX-VAL>DNR</OBX-VAL> > </OBX> > <OBX TStamp='9300001'> > <USID Id='5147'>MEAN PLATELET VOLUME</USID> > <OBX-VAL Units='fL'>9.3</OBX-VAL> > </OBX> > </OBR> > <OBR Id='22392248' PlacerId='222333444-2' TStamps='9300001'> > <USID Id='7069'>GENERAL SURVEY PROFILE</USID> > <OBX TStamp='9300001'> > <USID Id='1104'>GLUCOSE</USID> > <OBX-VAL Units='mG/dL' RefRange='7-22'>77</OBX-VAL> > <OBX-NOTE>GLUCOSE TEST > </OBX-NOTE> > </OBX> > <OBX TStamp='9300001'> > <USID Id='1137'>CALCIUM</USID> > <OBX-VAL Units='mG/dL' RefRange='2.5-4.5'>9.4</OBX-VAL> > <OBX-NOTE>Please note change in reference range effective 05/04/1998. > </OBX-NOTE> > </OBX> > </OBR> > </PID> > <MSH-RAW><![CDATA[ > MSH|^`\&||labtstn||cabtstn|199908020046||ORU|57922001|D|2.2 > PID|1|111222333|22392248||Smith^Jane||19170615|M > OBR|1|222333444-1|22392248|7010^COMPLETE BLOOD COUNT^LOCAL|||19980529|||||||199805292311||1352|| > OBX|1|ST|5101^REMARKS^LOCAL||DNR||||||F|||199908020046 > OBX|2|ST|5147^MEAN PLATELET VOLUME^LOCAL||9.3|fL|||||F|||199908020046 > OBR|2|222333444-2|22392248|7069^GENERAL SURVEY PROFILE^LOCAL|||19980529|||||||199805292311||1352|| > OBX|1|ST|1104^GLUCOSE^LOCAL||77|mG/dL|7-22||||F|||199908020046 > OBX|2|ST|1137^CALCIUM^LOCAL||9.4|mG/dL|2.5-4.5||||F|||199908020046 > NTE|1|| Please note change in reference range effective 05/04/1998. > NTE|2|| > ]]> > </MSH-RAW> > </MSH> > <MSH Origin='labtstn' Dest='cabtstn' TStamp='93000000' Type='ORU' > Id='57922002'> > <PID Id='11248756' ExtId='444555666' Name='Johnson^Susan' > DOB='19580407' Sex='F'> > <OBR Id='11248756' PlacerId='222333555-1' TStamps='9300001'> > <USID Id='2505'>THYROXINE, TOTAL (T4)</USID> > <USID Coding='LOINC' Id='3062-2'></USID> > <OBX TStamp='9300001'> > <USID Id='2505'>THYROXINE, TOTAL (T4)</USID> > <OBX-VAL Units='uG/dL' RefRange='27-40'>9.9</OBX-VAL> > </OBX> > </OBR> > <OBR Id='11248756' PlacerId='222333555-2' TStamps='9300001'> > <USID Id='2511'>T3 UPTAKE (T3U)</USID> > <USID Coding='LOINC' Id='3050-2'></USID> > <OBX TStamp='9300001'> > <USID Id='2511'>T3 UPTAKE (T3U)</USID> > <OBX-VAL Units='%' RefRange='27-40'>37</OBX-VAL> > </OBX> > </OBR> > </PID> > <MSH-RAW><![CDATA[ > MSH|^`\&||labtstn||cabtstn1|199908020046||ORU|57922001|D|2.2 > PID|2|444555666|11248756||Johnson^Susan||19580407|F > OBR|1|222333555-1|11248756|2505^THYROXINE, TOTAL (T4)^LOCAL^3062-2^^LOINC|||19950511|||||||199505112034||1728|| > OBX|1|ST|2505^THYROXINE, TOTAL (T4)^LOCAL||9.9|uG/dL|27-40||||F|||199908020046 > OBR|2|222333555-2|11248756|2511^T3 UPTAKE (T3U)^LOCAL^3050-2^^LOINC|||19950511|||||||199505112034||1728|| > OBX|1|ST|2511^T3 UPTAKE (T3U)^LOCAL||37|%|27-40||||F|||199908020046 > ]]> > </MSH-RAW> > </MSH> > > <MSH Origin='labtstn' Dest='cabtstn' TStamp='93000000' Type='ORU' > Id='57922001'> > <PID Id='22392248' ExtId='111222333' Name='James^Robert' > DOB='19530615' Sex='M'> > <OBR Id='11248756' PlacerId='222333555-1' TStamps='9300001'> > <USID Id='2505'>THYROXINE, TOTAL (T4)</USID> > <USID Coding='LOINC' Id='3062-2'></USID> > <OBX TStamp='9300001'> > <USID Id='2505'>THYROXINE, TOTAL (T4)</USID> > <OBX-VAL Units='uG/dL' RefRange='27-40'>9.9</OBX-VAL> > </OBX> > </OBR> > <OBR Id='11248756' PlacerId='222333555-2' TStamps='9300001'> > <USID Id='2511'>T3 UPTAKE (T3U)</USID> > <USID Coding='LOINC' Id='3050-2'></USID> > <OBX TStamp='9300001'> > <USID Id='2511'>T3 UPTAKE (T3U)</USID> > <OBX-VAL Units='%' RefRange='27-40'>37</OBX-VAL> > </OBX> > </OBR> > <OBR Id='22392248' PlacerId='222333444-1' TStamps='9300001'> > <USID Id='7010'>COMPLETE BLOOD COUNT</USID> > <OBX TStamp='9300001'> > <USID Id='5101'>REMARKS</USID> > <OBX-VAL>DNR</OBX-VAL> > </OBX> > <OBX TStamp='9300001'> > <USID Id='5147'>MEAN PLATELET VOLUME</USID> > <OBX-VAL Units='fL'>9.3</OBX-VAL> > </OBX> > </OBR> > <OBR Id='22392248' PlacerId='222333444-2' TStamps='9300001'> > <USID Id='7069'>GENERAL SURVEY PROFILE</USID> > <OBX TStamp='9300001'> > <USID Id='1104'>GLUCOSE</USID> > <OBX-VAL Units='mG/dL' RefRange='7-22'>77</OBX-VAL> > <OBX-NOTE>GLUCOSE TEST > </OBX-NOTE> > </OBX> > <OBX TStamp='9300001'> > <USID Id='1137'>CALCIUM</USID> > <OBX-VAL Units='mG/dL' RefRange='2.5-4.5'>9.4</OBX-VAL> > <OBX-NOTE>Please note change in reference range effective 05/04/1998. > </OBX-NOTE> > </OBX> > </OBR> > </PID> > <MSH-RAW><![CDATA[ > MSH|^`\&||labtstn||cabtstn|199908020046||ORU|57922001|D|2.2 > PID|1|111222333|22392248||Smith^Jane||19170615|M > OBR|1|222333444-1|22392248|7010^COMPLETE BLOOD COUNT^LOCAL|||19980529|||||||199805292311||1352|| > OBX|1|ST|5101^REMARKS^LOCAL||DNR||||||F|||199908020046 > OBX|2|ST|5147^MEAN PLATELET VOLUME^LOCAL||9.3|fL|||||F|||199908020046 > OBR|2|222333444-2|22392248|7069^GENERAL SURVEY PROFILE^LOCAL|||19980529|||||||199805292311||1352|| > OBX|1|ST|1104^GLUCOSE^LOCAL||77|mG/dL|7-22||||F|||199908020046 > OBX|2|ST|1137^CALCIUM^LOCAL||9.4|mG/dL|2.5-4.5||||F|||199908020046 > NTE|1|| Please note change in reference range effective 05/04/1998. > NTE|2|| > ]]> > </MSH-RAW> > </MSH> > > <MSH Origin='labtstn' Dest='cabtstn' TStamp='93000000' Type='ORU' > Id='57922001'> > <PID Id='22392248' ExtId='111222333' Name='Donneley^Floyd' > DOB='19620705' Sex='M'> > <OBR Id='22392248' PlacerId='222333444-1' TStamps='9300001'> > <USID Id='7010'>COMPLETE BLOOD COUNT</USID> > <OBX TStamp='9300001'> > <USID Id='5101'>REMARKS</USID> > <OBX-VAL>DNR</OBX-VAL> > </OBX> > <OBX TStamp='9300001'> > <USID Id='5147'>MEAN PLATELET VOLUME</USID> > <OBX-VAL Units='fL'>9.3</OBX-VAL> > </OBX> > </OBR> > <OBR Id='22392248' PlacerId='222333444-2' TStamps='9300001'> > <USID Id='7069'>GENERAL SURVEY PROFILE</USID> > <OBX TStamp='9300001'> > <USID Id='1104'>GLUCOSE</USID> > <OBX-VAL Units='mG/dL' RefRange='7-22'>77</OBX-VAL> > <OBX-NOTE>GLUCOSE TEST > </OBX-NOTE> > </OBX> > <OBX TStamp='9300001'> > <USID Id='1137'>CALCIUM</USID> > <OBX-VAL Units='mG/dL' RefRange='2.5-4.5'>9.4</OBX-VAL> > <OBX-NOTE>Please note change in reference range effective 05/04/1998. > </OBX-NOTE> > </OBX> > </OBR> > </PID> > <MSH-RAW><![CDATA[ > MSH|^`\&||labtstn||cabtstn|199908020046||ORU|57922001|D|2.2 > PID|1|111222333|22392248||Smith^Jane||19170615|M > OBR|1|222333444-1|22392248|7010^COMPLETE BLOOD COUNT^LOCAL|||19980529|||||||199805292311||1352|| > OBX|1|ST|5101^REMARKS^LOCAL||DNR||||||F|||199908020046 > OBX|2|ST|5147^MEAN PLATELET VOLUME^LOCAL||9.3|fL|||||F|||199908020046 > OBR|2|222333444-2|22392248|7069^GENERAL SURVEY PROFILE^LOCAL|||19980529|||||||199805292311||1352|| > OBX|1|ST|1104^GLUCOSE^LOCAL||77|mG/dL|7-22||||F|||199908020046 > OBX|2|ST|1137^CALCIUM^LOCAL||9.4|mG/dL|2.5-4.5||||F|||199908020046 > NTE|1|| Please note change in reference range effective 05/04/1998. > NTE|2|| > ]]> > </MSH-RAW> > </MSH> > > XSL FILE: > 19990917_Batch_File_XML_HL7_mod_20_Donneley^Floyd.xsl > > > <?xml version="1.0"?> > > <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> > > > <xsl:template match="/"> > <!--this template is applied to the root element--> > <HTML> > <HEAD> > <TITLE> > <xsl:value-of select="HL7A1/MSH"/> > </TITLE> > </HEAD> > <BODY> > <xsl:apply-templates select="HL7A1/MSH/PID[@Name = 'Donneley^Floyd']" order-by = "+@Name" /> > <!--insert the results of another template identified by the value of > the "select" attribute--> > </BODY> > </HTML> > </xsl:template> > > <!--closes out main template--> > > <!--This template creates a table and begins populating it --> > > <xsl:template match="HL7A1/MSH/PID"> > <TABLE width="100%" border="1" bgcolor="blue"> > > <TR bgcolor="green" width="100%" valign="top"> > > <TD width="16%" valign="top"> > NAME: > <BR></BR> > <xsl:value-of select="@Name"/> > </TD> > > <TD width="16%" valign="top"> > <FONT color="black"> > DOB: > <BR></BR> > <xsl:value-of select="@DOB"/> > </FONT> > </TD> > > <TD width="16%" valign="top"> > <FONT color="black"> > SEX: > <BR></BR> > <xsl:value-of select="@Sex"/> > </FONT> > </TD> > > <TD width="16%" valign="top"> > <FONT color="black"> > External ID: > <BR></BR> > <xsl:value-of select="@ExtId"/> > </FONT> > </TD> > > <TD width="16%" valign="top"> > <FONT color="black"> > ID: > <BR></BR> > <xsl:value-of select="@Id"/> > </FONT> > </TD> > > <TD width="16%" valign="top"> > </TD> > > </TR> > > <xsl:apply-templates select="OBR"/> > <!--insert the results of another template identified by the value of > the "select" attribute--> > </TABLE> > </xsl:template> > > <xsl:template match="HL7A1/MSH/PID/OBR"> > > > <TR bgcolor="yellow" valign="top"> > > <TD width="16%" valign="top"> > <FONT color="black"> > ORDER: <BR></BR><xsl:value-of select="USID"/> > </FONT> > </TD> > > <TD width="16%" valign="top"> > <FONT size="-1" color="black">Orgin: </FONT> > <BR></BR> > <FONT size="-5" color="black"><xsl:value-of select="../../@Origin"/></FONT> > > </TD> > > <TD width="16%" valign="top"> > <FONT size="-1" color="black">Destination: </FONT> > <BR></BR> > <FONT size="-5" color="black"><xsl:value-of select="../../@Dest"/></FONT> > </TD> > > <TD width="16%" valign="top"> > <FONT size="-1" color="black">Identification: </FONT> > <BR></BR> > <FONT size="-5" color="black"><xsl:value-of select="../../@Id"/></FONT> > </TD> > > <TD width="16%" valign="top"> > <FONT size="-1" color="black">Time Stamp: </FONT> > <BR></BR> > <FONT size="-5" color="black"><xsl:value-of select="../../@TStamp"/></FONT> > </TD> > > > <TD width="16%" valign="top"> > <FONT size="-1" color="black">Message Type: </FONT> > <BR></BR> > <FONT size="-5" color="black"><xsl:value-of select="../../@Type"/></FONT> > </TD> > > > > </TR> > > <xsl:apply-templates select="OBX"/> > <!--insert the results of another template identified by the value of > the "select" attribute--> > </xsl:template> > > <xsl:template match="HL7A1/MSH/PID/OBR/OBX"> > > <TR bgcolor="white"> > > <TD width="16%" align="left"> > <FONT size="-1" color="black">TIME STAMP:</FONT> > <BR></BR> > <FONT size="-5" color="black"><xsl:value-of select="@TStamp"/></FONT> > </TD> > > <TD width="16%" align="left"> > <FONT size="-1" color="black">TEST:</FONT> > <BR></BR> > <FONT size="-5" color="black"><xsl:value-of select="USID"/></FONT> > </TD> > > <TD width="16%" align="left"> > <FONT size="-1" color="black">RESULT:</FONT> > <BR></BR> > <FONT size="-5" color="black"><xsl:value-of select="OBX-VAL"/></FONT> > </TD> > > > <TD width="16%" align="left"> > <FONT size="-1" color="black">UNITS:</FONT> > <BR></BR> > <FONT size="-5" color="black"><xsl:value-of select="OBX-VAL/@Units"/></FONT> > </TD> > > <TD width="16%" align="left"> > <FONT size="-1" color="black">NORMAL RANGE:</FONT> > <BR></BR> > <FONT size="-5" color="black"><xsl:value-of select="OBX-VAL/@RefRange"/></FONT> > </TD> > > <xsl:apply-templates select="OBX-NOTE"/> > > <!--insert the results of another template identified by the value of > the "select" attribute--> > > </TR> > > </xsl:template> > > <xsl:template match="HL7A1/MSH/PID/OBR/OBX/OBX-NOTE"> > > <TD width="16%" bgcolor="red" valign="top"> > <FONT size="-1" color="black">NOTES: <BR></BR></FONT> > <FONT size="-5" color="black"><xsl:value-of select="../OBX-NOTE"/></FONT> > </TD> > > </xsl:template> > > <!-- close the template that creates the table --> > > <!-- once this template has run it's course, our table is completely > populated --> > > <xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template> > > <xsl:template match="text()"><xsl:value-of select="."/></xsl:template> > > </xsl:stylesheet> > > __________________________________________________ Do You Yahoo!? Bid and sell for free at http://auctions.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Announcing yet another XSLT-bas, James Tauber | Thread | position() and last(), Emmanuel.Leguy |
Announcing yet another XSLT-based p, Pim van der Eijk | Date | position() and last(), Emmanuel.Leguy |
Month |