XSLT - Creating a template for a XML NodeSet that has different tags

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi all, I am not even sure this is possible since you cannot construct XPath dynmically, but here it goes..<br/> <br/> Ok, I have the following terrible XML...<br/> <br/>
<pre lang=x-xml><judgement>
<director1>
<positiondirector1/>
<surnameddirector1/>
<numberinroaddirector1/>
<letterinroaddirector1/>
<roaddirector1/>
<postcodedirector1/>
<municipalitydirector1/>
</director1>
<director2>
<positiondirector2/>
<surnameddirector2/>
<numberinroaddirector2/>
<letterinroaddirector2/>
<roaddirector2/>
<postcodedirector2/>
<municipalitydirector2/>
</director2>
</judgement>[/code]
My plan was to create a template that could manage <director1> and <director2> at the same time. Is it even possible for me handle them?<br/> <br/> This is what I have come up with so far?<br/> <br/>
<pre lang=x-xml><xsl:apply-templates select="director1|director2" mode="NegativeInformation" />[/code]
<pre lang=x-xml> <!-- XSLT Template for each Liquidator. -->
<xsl:template match="director1|director2" mode="NegativeInformation
<Liquidator>
<xsl:value-of select="positiondirector1" /> : <xsl:value-of select="surnameddirector1" /> - <xsl:value-of select="numberinroaddirector1" />
</Liquidator>
</xsl:template>[/code]
<br/> If it is possible I guess I need to somehow get the last character of the XML element that is matched and then append it to the Xpathed values being used (minus the last character)?<br/> <br/> If I am going down a deadend with this, please let me know.<br/> <br/> Thanks<br/> <br/> <br/> <br/> <br/> <br/> <br/><hr class="sig Tryst

View the full article
 
Back
Top