Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: [XSLT] How to establish a context node without [XSLT] How to establish a context node without 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 | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
