RE: [xsl] Replacing default namespace

Subject: RE: [xsl] Replacing default namespace
From: "Paul Kiel" <paul@xxxxxxxxxxxxxxx>
Date: Mon, 2 Jul 2007 11:33:19 -0400
This seems like you are trying to have a "find and replace" kind of
solution.  If you are working in raw text, this works.  In an xmlns aware
setting, then you need to copy the nodes into the new namespace.  This has
to be done via one of the options presented, such as using "local-name()"
(which I've used many times to do this) or the namespace-uri match approach
suggested by Abel.

fwiw,
Paul Kiel
 




=====================================================
W. Paul Kiel
XmlHelpline.com Consulting
paul@xxxxxxxxxxxxxxx
work: 919-846-0224
cell: 919-449-8801
website: http://www.xmlhelpline.com
Your helpline for Xml, Xslt, and data integration solutions.
=====================================================




-----Original Message-----
From: Scott Sauyet [mailto:lists@xxxxxxxxxx] 
Sent: Monday, July 02, 2007 10:55 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Replacing default namespace

Martin Honnen wrote:
> Abel Braaksma wrote:

There was lots of good advice from both of you.  Thank you.

But I think I went about asking the questions completely wrong.  I 
shouldn't have shown some of the extra details or even my incomplete 
solution.  I guess what I'd like to know is how to convert the WSDL 
listed below into a very similar one, with only the minor change in the 
namespace declaration and the targetNamespace attribute of the root element.

There are other things that I will need to do, but if I can't figure out 
how to combine them with these changes, I can easily do two XSLT passes. 
  This will be used in a code-generation phase of a build process where 
the inputs will change infrequently, and which will therefor only run 
occasionally, and so multiple steps would be fine.  I'm afraid I muddied 
the waters last time with additional details.

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/";
         ...

Thank you very much for your help,

   -- Scott

-------------------- original WSDL --------------------
<?xml version="1.0" encoding="UTF-8"?>
<definitions
     targetNamespace="http://tempuri.org/";
     xmlns:tns="http://tempuri.org/";
     xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/";
     xmlns:xs="http://www.w3.org/2001/XMLSchema";
     xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
     xmlns:ro="urn:Databox"
     xmlns:n1="http://schemas.xmlsoap.org/wsdl/";
     xmlns="http://schemas.xmlsoap.org/wsdl/";
 >
    <types>
       <xs:schema targetNamespace="urn:Databox" xmlns="urn:Databox">
          <xs:simpleType name="enDataboxErrors">
             <xs:restriction base="xs:string">
                <xs:enumeration value="erOK" />
                <xs:enumeration value="erInvalidUser" />
                <!-- Many more <xs:enumeration> items here -->
             </xs:restriction>
          </xs:simpleType>
          <!-- Many more <xs:simpleType> and
               <xs:complexType> items here -->
       </xs:schema>
    </types>
    <message name="Sessions_OpenRequest">
       <part name="UserName" type="xs:string"/>
       <part name="Password" type="xs:string"/>
       <part name="StationName" type="xs:string"/>
    </message>
    <message name="Sessions_OpenResponse">
       <part name="SessionTimeoutSecs" type="xs:int"/>
       <part name="SessionToken" type="xs:string"/>
    </message>
    <!-- Many more messages -->
    <portType name="Sessions">
       <operation name="Open">
          <input message="tns:Sessions_OpenRequest"/>
          <output message="tns:Sessions_OpenResponse"/>
       </operation>
       <!-- Many more operations -->
    </portType>
    <binding name="SessionsBinding" type="tns:Sessions">
       <soap:binding style="rpc"
                     transport="http://schemas.xmlsoap.org/soap/http"/>
          <operation name="Open">
             <soap:operation soapAction="urn:Databox-Sessions#Open"
                             style="rpc"/>
             <input>
                <soap:body use="encoded" encodingStyle=
                           "http://schemas.xmlsoap.org/soap/encoding/";
                           namespace="urn:Databox-Sessions"/>
             </input>
             <output>
                <soap:body use="encoded" encodingStyle=
                           "http://schemas.xmlsoap.org/soap/encoding/";
                           namespace="urn:Databox-Sessions"/>
             </output>
          </operation>
          <!-- Many more operations -->
    </binding>
    <service name="SessionsService">
       <documentation/>
       <port name="SessionsPort" binding="tns:SessionsBinding">
          <soap:address location="http://localhost:8099/SOAP"/>
       </port>
    </service>
</definitions>

Current Thread