RE: [xsl] substring-before<tab/>... substring-after<tab/> take 2

Subject: RE: [xsl] substring-before<tab/>... substring-after<tab/> take 2
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Mon, 24 Feb 2003 17:04:46 -0000
> I am sorry to pester again, but nobody has had a response... Is this 
> impossible to do in straight XSLT???

I saw a response... But you didn't get many responses because you didn't
phrase the question very clearly.

Will there always be exactly one <tab/> element, or is it a variable
number? Are there other elements that can appear?

The simplest solution to this is to ignore the <tab/> elements and
process the text nodes, but it is a bit sensitive to the presence of
extraneous things like comments. Just do

<xsl:template match="para">
<xsl:for-each select="text()">
  <td><xsl:copy-of select="."/></td>

This may give you problems with MSXML3, which doesn't always normalize
text nodes properly.

A more robust solution would be to recurse over the siblings, something

<xsl:template match="para">
  <xsl:apply-template select="child::node()[1]" mode="along"/>

<xsl:template match="tab | text()[1]" mode="along">
match="following-sibling::node()[1][self::text()]" mode="along"/>
  <xsl:apply-templates match="following-sibling::tab"/>

<xsl:template match="text()" mode="along">
 <xsl:apply-templates match="following-sibling::node()[1][self::text()]"

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 
> (From my Friday email)
> I am trying to get the text before and after the <tab/> 
> demarcation in 
> order to insert the strings into separate fields in a table.
> <!-- using xsl:copy-of -->        
>                  <para style="T2">Provider<tab/>The name of 
> the provider 
> to use for the connection.</para>
> I can't think of a way to get the information separated... 
> when I output 
> the <xsl:value-of> on  the same node I get:
> <para>ProviderThe name of the provider to use for the 
> connection.</para>
> I looked on the FAQs and archives but I didn't quite know how to word 
> this query.
> Any suggestions would be greatly appreciated!
> Thank you in advance and Happy Monday (if that isn't too much of an 
> oxymoron)
> Deb Berkson
>  XSL-List info and archive:

 XSL-List info and archive:

Current Thread