xsl-list
[Top] [All Lists]

Re: [xsl] Namespace de-duplication for dynamically generated elements

2008-09-09 04:37:33
After a long struggle, I've managed some hacky XSLT which manages the
namespace mapping from strings and NS declarations to prefixed QName
elements, however I end up getting the xmlns:pt="urn:ex" element on *every*
leaf element (e.g. <go:zip xmlns:go="urn:ex">), rather than just once on the
document element as I would like it:

Does anyone know of any tricks to avoid this situation?


You need to generate the namespace higher up in the tree, either by
creating it manually or by inserting a node that requires it.  I would
say the best thing to do is a two pass transform (first pass in a
variable) where the second pass just copies all namespaces to the root
node - a step which tidies the XML for human consumption if you like,
which you can remove down the line if needed.

If you stick with a single pass, you'll need to create the namespace
nodes manually when you output the root node, and then again when you
process further down the tree.



-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--