Re: [xsl] Global namespace prefixes (Corrected Examples)

Subject: Re: [xsl] Global namespace prefixes (Corrected Examples)
From: Nathan Potter <ndp@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 13 Nov 2008 15:51:08 -0800
On Nov 13, 2008, at 3:30 PM, Michael Kay wrote:


The crux of my question is this:

Is there a way to get namespace prefix declarations into the
root element of the result tree through the XSLT API?

With XSLT 2.0, use the xsl:namespace instruction



I'm stuck with XSLT 1.0



With XSLT 1.0, you can use xsl:copy-of to copy a namespace node from the
source document to the result document.

But that only works if the namespace exists in the source document.


In my situation I am using information found in the source document to create a new namespace.

The intention is that every Attribute element gets recast to a new element in a namespace that is unique to the base.document.

So these:

<?xml version="1.0" encoding="UTF-8"?>
<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>


Currently become this:

<?xml version="1.0" encoding="UTF-8"?>
<output xmlns:dap="http://xml.opendap.org/ns/DAP/3.2#";>
<ns0:Conventions xmlns:ns0="http://base.document/att#";>CF-1.0</ ns0:Conventions>
<ns1:logname xmlns:ns1="http://base.document/att#";>olson</ns1:logname>
<ns2:host xmlns:ns2="http://base.document/att#";>bb0001en</ns2:host>
</output>



Which is correct, but what I am trying to get is this:



<?xml version="1.0" encoding="UTF-8"?>
<output xmlns:dap="http://xml.opendap.org/ns/DAP/3.2#"; xmlns:att="http://base.document/att# ">
<att:Conventions>CF-1.0</ttt:Conventions>
<att:logname>olson</att:logname>
<att:host>bb0001en</att:host>
</output>







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


============================================================ 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

Current Thread