Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Identitity Template Problem - Best Practices - What order to make changes

From: Joe Kesselman <keshlam.cat.nospam@-------.--->
To: NULL
Date: 10/18/2009 9:02:00 PM
johkar wrote:
> 1) Do I work from the root element and go deeper so that I don't
> overwrite...in general what is the best strategy?

You can't "overwrite" using XSLT. Things are output in the order, and 
nesting, that the stylesheet outputs them in. Focus on what you want to 
output and where you want to draw the information from. If the output 
document will follow roughly the same structure as the input document, a 
simple recursive tree walk via the xsl:apply-template operation and a 
template for each node that needs special handling (typically with the 
identity template as a catch-all for those nodes which can be copied 
through unchanged) is best practice. In those places where the output 
diverges from that structure, write the stylesheet logic "pull-style" -- 
generate the appropriately nested elements/attributes/text, with 
xsl:value or attribute value templates used to explicitly retrieve the 
information.

> 2) Do I have one identity template and one primary template match that
> I put all my apply-templates within so that nothing is copied to the
> output until all changes are made?

XSLT does not "make changes". It generates a new output document, which 
is typically (but not guaranteed to be) written to the output as 
stylesheet processing takes place. If that isn't acceptable, I'd suggest 
you have the stylesheet write to a buffer of some variety -- eg, build a 
DOM tree -- which you can then process atomically.

> 3) How can I use a common template to strip currency formatting for
> any section of the XML that I might also be doing other changes too?

See the xsl:call-template operation, which essentially lets you use a 
named template as a subroutine for other templates.


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