[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: substring-before<tab/>... substring-after<tab/> ta

Subject: RE: substring-before<tab/>... substring-after<tab/> take 2
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Mon, 24 Feb 2003 17:04:46 -0000
xsl substring before
> 
> 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>
</xsl:for-each>

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
like

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

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

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

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:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.