Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: search and replace kind of operations with XML

From: "Michael Kay" <mike@--------.--->
To: "'dave'" <ceek63@-----.--->, <xmlschema-dev@--.--->
Date: 2/7/2008 9:45:00 AM

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="*">
  <xsl:copy>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

(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
<cost>10.00</cost>

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

Hope this helps.

Michael Kay
http://www.saxonica.com/


From petexmldev@c... Thu Feb 07 10:22:43 2008
Received: from aji.w3.o


transparent
Print
Mail
Like It
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