I have an XSLT script collection that converts messed up XML to usuable XML.
Instead of generic template matching, I want to establish a context node for
some branches so that I don't have to rely on absolute path. Here's a
simplified version of my work:
[root.xsl]:
<xsl:include href="common.xs l"/>
<xsl:template match="/">
<patientDisk>
<xsl:call-template name="patientDa ta"/>
</patientDisk>
</xsl:template>
=============== =============== ====
[patientData.xsl]:
<xsl:template name="patientDa ta">
<birthyear>
<xsl:value-of
select="documen t('rpt_pat.xml' )//parameter[@name='PatientB irthYear']"/>
</birthyear>
<gender>
<xsl:value-of
select="documen t('rpt_pat.xml' )//parameter[@name='PatientG ender]"/>
</gender>
</xsl:template>
Instead of specifying document('rpt_p at.xml') every time using absolute
paths, I could have used <xsl:for-each select=document ('rpt_pat.xml') >.
However, I'd like to avoid using this syntax because there's only one
instance of document('rpt_p at.xml') node. Using <xsl:for-eachcan lead to
whoever that reads my XSLT scripts into thinking that there are multiple
instances of the document('rpt_p at.xml') node, adding confusion to the
already huge chaos.
I'd like to avoid <xsl:template match="(somethi ng)"because some tags have
the same names in the messy XML files that I'm trying to parse, and they can
be distinguished only by observing the hieracy (which branch that XML tag is
under).
Can anybody suggest a neat way to do that? Thanks in advance.
-- Hoi
Instead of generic template matching, I want to establish a context node for
some branches so that I don't have to rely on absolute path. Here's a
simplified version of my work:
[root.xsl]:
<xsl:include href="common.xs l"/>
<xsl:template match="/">
<patientDisk>
<xsl:call-template name="patientDa ta"/>
</patientDisk>
</xsl:template>
=============== =============== ====
[patientData.xsl]:
<xsl:template name="patientDa ta">
<birthyear>
<xsl:value-of
select="documen t('rpt_pat.xml' )//parameter[@name='PatientB irthYear']"/>
</birthyear>
<gender>
<xsl:value-of
select="documen t('rpt_pat.xml' )//parameter[@name='PatientG ender]"/>
</gender>
</xsl:template>
Instead of specifying document('rpt_p at.xml') every time using absolute
paths, I could have used <xsl:for-each select=document ('rpt_pat.xml') >.
However, I'd like to avoid using this syntax because there's only one
instance of document('rpt_p at.xml') node. Using <xsl:for-eachcan lead to
whoever that reads my XSLT scripts into thinking that there are multiple
instances of the document('rpt_p at.xml') node, adding confusion to the
already huge chaos.
I'd like to avoid <xsl:template match="(somethi ng)"because some tags have
the same names in the messy XML files that I'm trying to parse, and they can
be distinguished only by observing the hieracy (which branch that XML tag is
under).
Can anybody suggest a neat way to do that? Thanks in advance.
-- Hoi
Comment