Re: [xsl] Replacing default namespace

Subject: Re: [xsl] Replacing default namespace
From: Scott Sauyet <lists@xxxxxxxxxx>
Date: Mon, 02 Jul 2007 15:24:54 -0400
Martin Honnen wrote:
Scott Sauyet wrote:

In any case, a reduced version of the input WSDL is below. I want the output to be exactly the same except for the changes to the root tag:

    <definitions
        targetNamespace="http://my.new.namespace/";
        xmlns:tns="http://my.new.namespace/";

Here is an XSLT 1.0 stylesheet, I think it does what you want with Saxon 6.5.5:

Thank you very much. That did exactly what I was looking for. And I think (or at least hope) I'm learning something from it. I haven't used XSLT all that much, and when I do, I think of it as transformations of elements. Other nodes have always just been modifications to those nodes. You code points out what should be obvious, but which I've always overlooked, that my templates can match attribute nodes just as easily. That makes all sorts of processing that I've previously struggled through much easier to accomplish.


The other thing I need to do is get Saxon into my regular routine. When I process this from Xalan (whatever version is the default when running Ant 1.7.0 against Java 1.6.0_01), I get a document which presumably has the same information, but which is cluttered up with additional redundant namespace declarations, one for each element in the original without an explicit namespace, and each one pointing to the WSDL namespace. It's an annoying issue that may have hidden from me that several earlier attempts were actually working correctly.

Something like this:

   <ns2:message xmlns:ns2="http://schemas.xmlsoap.org/wsdl/";
                name="Sessions_OpenRequest">
      <ns3:part xmlns:ns3="http://schemas.xmlsoap.org/wsdl/";
                name="UserName" type="xs:string"/>
      <ns4:part xmlns:ns4="http://schemas.xmlsoap.org/wsdl/";
                name="Password" type="xs:string"/>
      <ns5:part xmlns:ns5="http://schemas.xmlsoap.org/wsdl/";
                name="StationName" type="xs:string"/>
   </ns2:message>

instead of:

   <message name="Sessions_OpenRequest">
      <part name="UserName" type="xs:string"/>
      <part name="Password" type="xs:string"/>
      <part name="StationName" type="xs:string"/>
   </message>

Clearly there's no real harm in Xalan's code, but damn, it's ugly!

In any case, thank you for your help.

-- Scott

Current Thread