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

Re: replace xml element

Subject: Re: replace xml element
From: Mike Brown <mike@xxxxxxxx>
Date: Wed, 1 May 2002 19:23:04 -0600 (MDT)
xslt replace br
valerie liston wrote:
> Thanks Jeni, I'll give that a try but also I was just wondering is there a
> possibility of doing some sort of search and replace in xslt, ie. search
> through the whole xml doc and replace any occurrence of the tag <break/>
> with <br/>?

XSLT doesn't operate on an XML document as a string, it operates on a node
tree (kind of like the one implied by the DOM). You don't have access to the
serialized markup, so the answer to your question is "no", if you're asking
what I think you're asking. However, the answer Jeni gave you was correct and
achieves what you want.

You can visit every node in the document, making a copy of it along the way.
When you are visiting an element named 'break', you can have it be processed
by a different template that creates an empty 'br' element.

The recursive visit-and-copy algorithm is called the 'identity transform' and 
is demonstrated in the XSLT spec in the section on copying (xsl:copy).
The template to add to that example is just like the one Jeni said:

<xsl:template match="break">
  <br/>
</xsl:template>

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

 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.