[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Global namespace prefixes
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="{@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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|