[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
David Carlisle wrote:
Tried a six line input.xml and some snippets of the .xsl processing as well as the sample output.html
------------
Input xml file:
Process xsl file:
<xsl:template....>
<xsl:variable name="notPresent" select="'Not Present'"/>
<xsl:for-each select="/*/*/B/Class[.=$notPresent]">
<xsl:variable name="clsName" select="..//preceding-sibling::A/Class/text()"/>
<xsl:choose>
<xsl:when test="matches($clsName,'(.)([A-Z])')"><!--only call the template if there is any word to split-->
<xsl:call-template name="splitTerm">
<xsl:with-param name="AName" select="$clsName"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<AWord>A Wrd: <xsl:value-of select="$clsName"/></AWord>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:template name="splitTerm">
<xsl:param name="AName"/>
<xsl:variable name="splitA" select="tokenize(replace($AName,'(.)([A-Z])','$1 $2'), ' ')"/>
<!-- if either token exists as a parent element elsewhere and has results in B node() then proceed to next.
E.g. tokens 'Second', 'Again' - 'Second' exists as <Second> in input file and has values in B/Class viz. 'Car' so proceed to next occurrence of 'Not Present'.
-->
</xsl:template>
Output file (HTML):
A Entries B Entries
------------------------
Hope this is slightly clearer. Else please let me know. I dont want to land up writing 10 lines of code when it can be done in 1.
Re: [xsl] building path expressions around dynamic element node names
Subject: Re: [xsl] building path expressions around dynamic element node names From: Rahil <qamar_rahil@xxxxxxxxxxx> Date: Wed, 18 May 2005 14:52:27 +0100 |
David Carlisle wrote:
You lost me there.
As always, a six line input file and a required result would be good
David
Tried a six line input.xml and some snippets of the .xsl processing as well as the sample output.html
------------
Input xml file:
<Top> <First> <A><Class id="123">First</Class></A> <B> <Class id="897">Not Present</Class></B> </First> <Second> <A> <Class id="567">Second</Class></A> <B><Class id="908">Car</Class></B> </Second> <SecondAgain> <A><Class id="567">SecondAgain</Class></A> <B><Class id="908">Not Present</Class></B> </SecondAgain> </Top>
Process xsl file:
<xsl:template....>
<xsl:variable name="notPresent" select="'Not Present'"/>
<xsl:for-each select="/*/*/B/Class[.=$notPresent]">
<xsl:variable name="clsName" select="..//preceding-sibling::A/Class/text()"/>
<xsl:choose>
<xsl:when test="matches($clsName,'(.)([A-Z])')"><!--only call the template if there is any word to split-->
<xsl:call-template name="splitTerm">
<xsl:with-param name="AName" select="$clsName"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<AWord>A Wrd: <xsl:value-of select="$clsName"/></AWord>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:template name="splitTerm">
<xsl:param name="AName"/>
<xsl:variable name="splitA" select="tokenize(replace($AName,'(.)([A-Z])','$1 $2'), ' ')"/>
<!-- if either token exists as a parent element elsewhere and has results in B node() then proceed to next.
E.g. tokens 'Second', 'Again' - 'Second' exists as <Second> in input file and has values in B/Class viz. 'Car' so proceed to next occurrence of 'Not Present'.
-->
</xsl:template>
Output file (HTML):
A Entries B Entries
First Not Present Second Car SecondAgain 'Occurs as Second'
------------------------
Hope this is slightly clearer. Else please let me know. I dont want to land up writing 10 lines of code when it can be done in 1.
Thanks Rahil
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] building path expressions, David Carlisle | Thread | Re: [xsl] building path expressions, omprakash . v |
[xsl] alternate background color fo, Ranjan K. Baisak | Date | Re: [xsl] XSL - Switching Order Ele, JBryant |
Month |