Re: [xsl] XSL Help!!

Subject: Re: [xsl] XSL Help!!
From: Gunther Schadow <gunther@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 05 Dec 2002 18:58:56 -0500


Chandra - wrote:

Hi there,
  I have a couple of questions on XSL stylesheets.
1)<xsl:template match="MEMBER">
     <xsl:apply-templates select="NAME"/>
     <xsl:apply-templates select="Phone[@type='work']"/>
</xsl:template>

When u say <xsl:apply-templates select="NAME"/>, Will all the NAME nodes under MEMBER be selected(say there are more than 1 NAME nodes under MEMBER)?


yes

Also will the NAME template rule be applied to each one of the NAME nodes before the Phone node is selected?


yes, and in that order you gave here, first all names then all
phones. With

<xsl:apply-templates select="(NAME|Phone[@type='work'])"/>

it they would appear instead in document order, which could be
Name-Phone-Name-Phone etc.


2)
<xsl:variable name='signers'
select=/legal_authenticator/person'/>
    <xsl:if test='$signers'>
.....
.....
</xsl:if>

What is the xsl:if tag doing here? Is it testing whether /legal_authenticator/person' exists??


yes, actually there are some pretty wild (but useful) rules by
which values are cast into the boolean type to make the test.
But and a non-existing node is false.


3)<person_name>
         <nm>
           <GIV V="Henry"/>
           <FAM V="Levin"/>
          </nm>
         <person_name.type_cd V="L" S="2d"/>
       </person_name>

For the above xml, I see the following in the stylesheet
<xsl:apply-templates select='person_name[person_name.type_cd/@V="L"]'/>
What do the [] mean?? Why can't I just have / instead of the []??


Hehe, I know this stuff you're doing. This is HL7 CDA schema
or something close of quite an outdated interim release, isn't
it? Funny how small the world is :-)

Well, this is a pretty basic XSLT question and you should want
to study XSLT in more detail (it's the coolest language there is.)
But since you seem to have to read XSLT from someone else and
since you are an HL7 fellow, here's the answer:

person_name[...] makes a condition on the person_name node, i.e.,
   the result is the person_name(s) if it exists AND if the
   condition term in the brackets is true.

This schema has changed a lot since then, you may want to update
to the more current specifications :-)

regards
-Gunther



--
Gunther Schadow, M.D., Ph.D.                    gschadow@xxxxxxxxxxxxxxx
Medical Information Scientist      Regenstrief Institute for Health Care
Adjunct Assistant Professor        Indiana University School of Medicine
tel:1(317)630-7960                         http://aurora.regenstrief.org



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread