xsl-list
[Top] [All Lists]

Re: Conditional extraction of data

2004-11-08 13:47:38

-- 
Bryan Rasmussen

damn, looking at this coming home it finally got through my head that he wanted
to strip elements other than tag2, whereas what i'd thought he wanted to do was
copy them, other than tag2. 

Quoting David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk>:



In other words I want all the text, but convert (in this example) all
the <b> tags to html <i> tags. 

this is just a simple case of the more general transform where you want
to change everything.
In your case you want to transform most elements by junking the element
node and taking its string value

<xsl:template match="anElement/*">
 <xsl:value-of select="."/>
</xsl:template>

then you want to do something different for b so


<xsl:template match="anElement/b" priority="2">
 <i><xsl:value-of select="."/></i>
</xsl:template>



again if you need to recursively apply processing to child elements
you may need to replace xsl:value-of by apply-templates.


In other words I want all the text, but convert (in this example) all
the <b> tags to html <i> tags.

Don't mention the T-word on XSL-list:-)

XSLT does not have access to the tags in your source document and can
not directly generate tags in the result. XSLT just works on trees of
nodes. An XML parser (may) be used to get an input tree from the tags in
a document and the result tree (may) be serialised to a text file as
text containing tags.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. 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
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--