[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: variables and inline tags
Spencer,
The tricky thing here is that to remove the comma without messing with the other nodes (as you discovered, when you use the value of the <def> its children aren't processed), you need to get at it all the way down at the level of the text node. But not just any text node is of interest -- actually it's only those that are the first thing inside a <def>, which have a comma. So: <xsl:template match="def/text()"> <!-- when a text node is inside a def, this template overrides the built-in template for text nodes, which simply copies out their values --> <xsl:when test="not(preceding-sibling::node() and starts-with(.,',')"> <!-- truncates the first character if it's a comma and this text node has no preceding siblings --> <xsl:value-of select="substring(., 2)"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="."/> </xsl:otherwise> </xsl:template> You may have to adjust this match pattern, or even construct a separate mode, to keep this sufficiently isolated from the way you want most text nodes to be processed. (I assume you generally don't want to truncate initial commas in text nodes.) And it will work irrespective of whether the results are bound to a variable, or simply copied out. If it's mysterious to you why this works -- like most XSLT mysteries, it comes back to the processing model (that is, what the processor does when you say "apply-templates" or let it default to that). I hope this helps, Wendell At 04:52 PM 5/4/2005, you wrote: Having problems with variables, applying templates and parsing strings. Been working on it all day and can't seem to wrap my mind around it. ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|