Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] replace xml element

From: Mike Brown <mike@-------->
To:
Date: 5/1/2002 5:17:00 PM
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


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent