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

Re: Putting characters in an element

Subject: Re: Putting characters in an element
From: Harm Kok <h.kok@xxxxxxxxxxxxxxx>
Date: Thu, 02 Oct 2003 15:34:53 +0200
harm kok
David,

Thanks, this is perfect. I searched the archives, but did not find this kind of solution.

Sergiu,
A "." can be used in an element name as long as it isn't the first character used. (same for "-", "_" and digits).


Thanks,

Harm


David Carlisle wrote:


This is a FAQ for both xslt 1 and 2, string oerations need strings as
input and get a string by taking the string value of any nodes supplied,
so all markup is lost on input to teh function, so clearly can't be
there on output.
li
You don't want to apply your regexp handler to the entire al node, just
its first child (if that is a text node)

so
<xsl:template match="al">
<xsl:variable name="first-string"
select="string(node()[1][self::text()]"/>
<xsl:variable name="rest" select="
 node()[1][not(self::text())]|node()[position()&gt;1]"/>

  <xsl:choose>
   <xsl:when test="matches($first-string,'\d.*')">
<li>
           <xsl:analyze-string select="." regex="^\d+\. ">
             <xsl:matching-substring>
               <nr><xsl:value-of select="."/></nr>
             </xsl:matching-substring>
             <xsl:non-matching-substring>
               <al><xsl:copy-of select="."/><xsl:copy-of select="$rest"/>
               </al>
             </xsl:non-matching-substring>
           </xsl:analyze-string>
       </li>
   </xsl:when>
   <xsl:otherwise>
<!-- you hardly _ever_ want to copy descendant::node() as you will get
   an exponention explosion in the size of the output, you just want
   child nodes, or as here the current node -->
       <xsl:copy-of select="."/>
   </xsl:otherwise>
   </xsl:choose>
</xsl:template>

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.