Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[XSLT] How to establish a context node without

From: "Hoi Wong" <wonghoi@--------.--->
To: NULL
Date: 11/17/2008 1:31:00 AM
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.xsl"/>

    <xsl:template match="/">
        <patientDisk>
            <xsl:call-template name="patientData"/>
        </patientDisk>
    </xsl:template>

==================================

[patientData.xsl]:

    <xsl:template name="patientData">
        <birthyear>
            <xsl:value-of 
select="document('rpt_pat.xml')//parameter[@name='PatientBirthYear']"/>
        </birthyear>
        <gender>
            <xsl:value-of 
select="document('rpt_pat.xml')//parameter[@name='PatientGender]"/>
        </gender>
    </xsl:template>


Instead of specifying document('rpt_pat.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_pat.xml') node. Using <xsl:for-each> can lead to 
whoever that reads my XSLT scripts into thinking that there are multiple 
instances of the document('rpt_pat.xml') node, adding confusion to the 
already huge chaos.

I'd like to avoid <xsl:template match="(something)"> 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 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent