Greetings,
I have the situation that I need to use (create elements in) a
namespace whose name is contained in, but not a declared namespace of,
the input document for my XSLT.
Input:
<Dataset xmlns="http://xml.opendap.org/ns/DAP/3.2#" base="http://base.document
">
<Attribute name="Conventions" >CF-1.0</Attribute>
<Attribute name="logname" />olson</Attribute>
<Attribute name="host" />bb0001en</Attribute>
</Dataset>
XSLT:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dap="http://xml.opendap.org/ns/DAP/3.2#"
>
<xsl:output method='xml' version='1.0' encoding='UTF-8'
indent='yes'/>
<xsl:template match="dap:Attribute" mode="body" >
<xsl:element name="{(_at_)name}" namespace="{/dap:Dataset/@base}/
att#"><xsl:value-of>.</xsl:value-of></xsl:element>
</xsl:template>
</xsl:stylesheet>
And this works:
<ns0:Conventions xmlns:ns131="http://base.document/att#">CF-1.0</
ns0:Conventions>
<ns1:logname xmlns:ns132="http://base.document/att#">olson</
ns1:logname>
<ns2:host xmlns:ns133="http://base.document/att#">bb0001en</
ns2:host>
However this bit of creating a new prefix for every element - even
though the namespace is the same - is a bit of a drag from a
readability standpoint. From what I can tell the only way to get a
single, global, namespace prefix into the result tree is for it to be
declared in the xsl:stylesheet element of the transform.
Is that true?
If so then I think that means I need to modify the xsl:stylesheet
document for each document processed.
Is that a reasonable design pattern?
Nathan
============================================================
Nathan Potter Oregon State University, COAS
ndp at coas.oregonstate.edu 104 Ocean. Admin. Bldg.
541 737 2293 voice Corvallis, OR 97331-5503
541 737 2064 fax
--~------------------------------------------------------------------
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>
--~--