5 Replies Latest reply on Apr 1, 2015 11:56 PM by siva_225147

    xslt component not adding xsi atrribute to the generated xml output

    siva_225147

      i am summarizing my problem in a shorter way where i can directly come to the problem.

       

      I have xslt which will accept soap envelope as an xml and remove the soap envelope and returns the xml which it will be used for further processing .but the generated xml is working fine but it unable to add add attribute to the xml element.

       

      request xml:

      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"

      xmlns:v1="http://types/resourceinventory/v1"

        xmlns:v11="http://types-unqualified/v1"

        xmlns:v12="http://commonbusinessentities/types-unqualified/v1"

        xmlns:v13="http://core/types-unqualified/v1"

        xmlns:v15="http://resource/types-unqualified-extended/v1" >

        <soapenv:Header>

        <wsse:Security

        xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"

        xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">

        <wsse:UsernameToken wsu:Id="UsernameToken-E35D486525CC9C0C7B142535531967512">

        <wsse:Username>ABCD</wsse:Username>

        <wsse:Password

        Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">EFGH</wsse:Password>

        </wsse:UsernameToken>

        </wsse:Security>

       

        </soapenv:Header>

        <soapenv:Body>

        <v1:searchAvailable >

        <!--1 or more repetitions: -->

        <v1:resourceSpec xsi:type="v15:REGFHJI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

        <v11:type>

        <v11:id>id</v11:id>

        <v11:name>TN</v11:name>

        </v11:type>

        <v15:Value>0000000</v15:Value>

        <v15:Subtype>LAT</v15:Subtype>

        <v15:ServiceCategory>GSMP</v15:ServiceCategory>

        </v1:resourceSpec>

        </v1:searchAvailable>

        </soapenv:Body>

      </soapenv:Envelope>

       

      2. this is the line where transformations are happening:

      <to uri="xslt:transformations/soap-enveloper-request-extractor.xsl?contentCache=false"/>

      3. XSLT:

      <xsl:stylesheet version="2.0"

                      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema"

                      xmlns:xhtml="http://www.w3.org/1999/xhtml"

                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"

                      exclude-result-prefixes="xhtml xsi">

       

       

          <xsl:output method="xml" omit-xml-declaration="yes" indent="no"/>

          <xsl:strip-space elements="*"/>

       

       

          <xsl:template match="/">

              <xsl:copy-of select="soapenv:Envelope/soapenv:Body/*" />

           

          </xsl:template>

        <xsl:template match="/*">

              <xsl:element name="{name()}" namespace="{namespace-uri()}">

                  <xsl:apply-templates select="@*|node()"/>

              </xsl:element>

          </xsl:template>

          <xsl:template match="/*/@xsi:*">

              <xsl:attribute name="other:{local-name()}" namespace="{namespace-uri()}">

                  <xsl:value-of select="."/>

              </xsl:attribute>

          </xsl:template>

          <xsl:template match="@*|node()">

              <xsl:copy>

                  <xsl:apply-templates select="@*|node()"/>

              </xsl:copy>

          </xsl:template>

        

        

      </xsl:stylesheet>

      5: Jboss fuse version jboss-fuse-6.1.0.redhat-379

      Java version 1.7.0_74

       

       

      Can any body suggest what is the problme why the  xslt component unable add xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" add resourceSpec?

       

      Any body have gone through the same issue?

       

      Thanks in advance.

        • 1. Re: xslt component not adding xsi atrribute to the generated xml output
          grgrzybek

          Hello

           

          Hmm, I used the information you provided to create a sample route, which does the transformation. And I got the following result (transformed) XML:

          <v1:searchAvailable xmlns:v1="http://types/resourceinventory/v1" xmlns:v11="http://types-unqualified/v1" xmlns:v15="http://resource/types-unqualified-extended/v1">
              <v1:resourceSpec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="v15:REGFHJI">
                  <v11:type>
                      <v11:id>id</v11:id>
                      <v11:name>TN</v11:name>
                  </v11:type>
                  <v15:Value>0000000</v15:Value>
                  <v15:Subtype>LAT</v15:Subtype>
                  <v15:ServiceCategory>GSMP</v15:ServiceCategory>
              </v1:resourceSpec>
          </v1:searchAvailable>
          

          What exactly do you want to get?

           

          regards

          Grzegorz Grzybek

          • 2. Re: xslt component not adding xsi atrribute to the generated xml output
            siva_225147

            Thanks Grzegorz,

            Have you run the code through fuse?

            what version of fuse?

            what version of java?

            what version of saxon?

             

            because this is the issue we are seeing when i deploy this as a bundle to the fuse, and invoke through soapui

             

            Reagrds

            • 3. Re: xslt component not adding xsi atrribute to the generated xml output
              grgrzybek

              Sorry for the delay.

              You're right - I was testing using correct version of Camel (2.12.0.redhat-379), but outside of Fuse.

              When tested inside Fuse, I got this:

              <v1:searchAvailable xmlns:v1="http://types/resourceinventory/v1"><!--1 or more repetitions: -->
                  <v1:resourceSpec xsi:type="v15:REGFHJI">
                      <v11:type xmlns:v11="http://types-unqualified/v1">
                          <v11:id>id</v11:id>
                          <v11:name>TN</v11:name>
                      </v11:type>
                      <v15:Value xmlns:v15="http://resource/types-unqualified-extended/v1">0000000</v15:Value>
                      <v15:Subtype xmlns:v15="http://resource/types-unqualified-extended/v1">LAT</v15:Subtype>
                      <v15:ServiceCategory xmlns:v15="http://resource/types-unqualified-extended/v1">GSMP</v15:ServiceCategory>
                  </v1:resourceSpec>
              </v1:searchAvailable>
              

              regards

              Grzegorz

              • 4. Re: xslt component not adding xsi atrribute to the generated xml output
                grgrzybek

                OK, the problem is related to https://issues.apache.org/jira/browse/CAMEL-7424 bug.

                This was fixed in JBoss Fuse starting from version camel-2.12.0.redhat-611424, so this fix should be already present i a patch.

                 

                After testing with this version, I got correct transformed XML with xmlns:xsi correctly declared.

                 

                best regards

                Grzegorz Grzybek

                • 5. Re: xslt component not adding xsi atrribute to the generated xml output
                  siva_225147

                  Thanks a lot Grzegorz. we are using camel-2.12.0.redhat-610379 version and need to be upgraded to camel-2.12.0.redhat-611424.