7 Replies Latest reply: Apr 28, 2013 9:59 AM by Rolando Carrasco RSS

    XSLT mapping

    Vinit Ahuja
      Hi,
      i have two schemas(xsds) . both source n target xsd's are same except their namespaces. As both having same element names, so i just want to copy all the elements of source to target.
      but i want that they maintain there namespaces. When i'm using 'copy-of' function in xslt, target xml is taking namespace from source.
      Is there any way to do it in xslt without mapping each n every element in jdev xslt designer as input xml is too large & it will be very tough to map everythg from designer.

      Thanks,
      Vinit
        • 1. Re: XSLT mapping
          Rolando Carrasco
          Is your message quite big?

          Have u tried assigning value by value inside an assign activity?

          The other option is that , once u get out of the transformation u mentioned, u just place a rename activity to get back to the desired namespace.

          hope that helps

          best
          • 2. Re: XSLT mapping
            Vinit Ahuja
            Thanks for replying.
            Yes the xml is big. There alot of unbounded elements. so quite tough to map each n every node.
            second problem is that i need to do it using mediator, so can't assign activity or rename . Have to handle this in transformation file of mediator.
            • 3. Re: XSLT mapping
              Rolando Carrasco
              I tried the followint XSLT:
              <?xml version="1.0" encoding="UTF-8" ?>
              <?oracle-xsl-mapper
              <!-- SPECIFICATION OF MAP SOURCES AND TARGETS, DO NOT MODIFY. -->
              <mapSources>
              <source type="WSDL">
              <schema location="../Mediator2.wsdl"/>
              <rootElement name="order" namespace="http://www.sourceNamespace.org"/>
              </source>
              </mapSources>
              <mapTargets>
              <target type="WSDL">
              <schema location="../Service1.wsdl"/>
              <rootElement name="order" namespace="http://www.targetNamespace.org"/>
              </target>
              </mapTargets>
              <!-- GENERATED BY ORACLE XSL MAPPER 11.1.1.6.0(build 111214.0600.1553) AT [SAT APR 27 12:15:36 CDT 2013]. -->
              ?>
              <xsl:stylesheet version="1.0"
              xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
              xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
              xmlns:mhdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.mediator.service.common.functions.MediatorExtnFunction"
              xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
              xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns:dvm="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue"
              xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
              xmlns:ns1="http://www.targetNamespace.org"
              xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
              xmlns:med="http://schemas.oracle.com/mediator/xpath"
              xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
              xmlns:bpm="http://xmlns.oracle.com/bpmn20/extensions"
              xmlns:ns0="http://oracle.com/sca/soapservice/TestXSLT/TestXSLT/Service1"
              xmlns:xdk="http://schemas.oracle.com/bpel/extension/xpath/function/xdk"
              xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
              xmlns:xsd="http://www.w3.org/2001/XMLSchema"
              xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
              xmlns:inp1="http://www.sourceNamespace.org"
              xmlns:bpmn="http://schemas.oracle.com/bpm/xpath"
              xmlns:ora="http://schemas.oracle.com/xpath/extension"
              xmlns:socket="http://www.oracle.com/XSL/Transform/java/oracle.tip.adapter.socket.ProtocolTranslator"
              xmlns:tns="http://xmlns.oracle.com/TestXSLT/TestXSLT/Mediator2"
              xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
              exclude-result-prefixes="xsi xsl xsd wsdl inp1 tns ns1 ns0 bpws xp20 mhdr bpel oraext dvm hwf med ids bpm xdk xref bpmn ora socket ldap">
              <xsl:template match="/">
              <ns1:order>
              <ns1:item>
              <xsl:value-of select="/inp1:order/inp1:item"/>
              </ns1:item>
              <ns1:quantity>
              <xsl:value-of select="/inp1:order/inp1:quantity"/>
              </ns1:quantity>
              <ns1:price>
              <xsl:value-of select="/inp1:order/inp1:price"/>
              </ns1:price>
              </ns1:order>
              </xsl:template>
              </xsl:stylesheet>



              The input message is this xsd:

              <?xml version="1.0" encoding="windows-1252" ?>
              <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
              xmlns="http://www.sourceNamespace.org"
              targetNamespace="http://www.sourceNamespace.org"
              elementFormDefault="qualified">
              <xsd:element name="order" type="orderType">
              <xsd:annotation>
              <xsd:documentation>
              A sample element
              </xsd:documentation>
              </xsd:annotation>
              </xsd:element>
              <xsd:complexType name="orderType">
              <xsd:sequence>
              <xsd:element name="item" type="xsd:string"/>
              <xsd:element name="quantity" type="xsd:integer"/>
              <xsd:element name="price" type="xsd:double"/>
              </xsd:sequence>
              </xsd:complexType>
              </xsd:schema>


              and the Target message is conatined in this XSD:

              <?xml version="1.0" encoding="windows-1252" ?>
              <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
              xmlns="http://www.targetNamespace.org"
              targetNamespace="http://www.targetNamespace.org"
              elementFormDefault="qualified">
              <xsd:element name="order" type="orderType">
              <xsd:annotation>
              <xsd:documentation>
              A sample element
              </xsd:documentation>
              </xsd:annotation>
              </xsd:element>
              <xsd:complexType name="orderType">
              <xsd:sequence>
              <xsd:element name="item" type="xsd:string"/>
              <xsd:element name="quantity" type="xsd:integer"/>
              <xsd:element name="price" type="xsd:double"/>
              </xsd:sequence>
              </xsd:complexType>
              </xsd:schema>


              They are equal, but the namespace is different.

              If u run the XSLT, the result is:

              <?xml version = '1.0' encoding = 'UTF-8'?>
              <ns1:order xmlns:ns1="http://www.targetNamespace.org">
              <ns1:item>item4</ns1:item>
              <ns1:quantity>5</ns1:quantity>
              <ns1:price>60.73</ns1:price>
              </ns1:order>


              Which is what u want. The sourceNamespace is transformed into the targetNamespace.

              Is strange what u r experiencing

              I hope I understood ur problem,

              best
              • 4. Re: XSLT mapping
                Vinit Ahuja
                Hi Ronaldo,
                Yes, this is my requirement. But the problem is that there are alot of complex type inside xsd n all are unbounded types n internal level of complex type reaches to 7 or 8.
                So, using 'Value-of' for each complex type would be tough..
                • 5. Re: XSLT mapping
                  Vinit Ahuja
                  Hi,It solved following below link :-

                  http://stackoverflow.com/questions/3463943/changing-namespace-for-xml-file-in-xsl-translation
                  • 6. Re: XSLT mapping
                    Vinit Ahuja
                    Thanks for your time @Ronaldo
                    • 7. Re: XSLT mapping
                      Rolando Carrasco
                      Great.
                      I'm glad u got it solved.

                      best
                      rolando