W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2008

RE: search and replace kind of operations with XML

From: Michael Kay <mike@saxonica.com>
Date: Thu, 7 Feb 2008 09:45:26 -0000
To: "'dave'" <ceek63@yahoo.com>, <xmlschema-dev@w3.org>
Message-ID: <013501c8696e$2b28eac0$6401a8c0@turtle>

I'm not sure why you're asking on an XML Schema list. 

I can't comment on XmlBeans, but you could do this either in XSLT or XQuery.
In my view XSLT works better than XQuery for this kind of transformation,
because of its built-in mechanism for doing a recursive descent of the tree,
applying rules as you go.

Typically you start with a rule that matches anything and copies it without
change, recursing to process the next level:

<xsl:template match="*">

(there are variations of this depending on whether and how you want to
process attributes)

and then you provide specific rules for each kind of element that needs to
be changed. For example the following rule changes <PRICE>12.00</PRICE> to

<xsl:template match="PRICE">
    <xsl:value-of select="format-number(. - 2, '#.00')"/>

Hope this helps.

Michael Kay
Received on Thursday, 7 February 2008 09:45:35 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:46 UTC