Невозможно правильно добавить пространство имен с помощью XSLT - PullRequest
0 голосов
/ 15 марта 2012

У меня одна проблема.

Ниже генерируется XML с использованием процесса Oracle BPEL

 <gdspCreateVpnNumberList xmlns:ws="http://ws.abc.com/" xmlns="http://ws.abc.com/">
                <ws:numberListName>SampleList105</ws:numberListName>
                <ws:numberListDesc>Desc</ws:numberListDesc>
                <ws:selectedCustomerId>200</ws:selectedCustomerId>
                <ws:numbersList>
                    <ws:number>21</ws:number>
                </ws:numbersList>
            </gdspCreateVpnNumberList>

Я применил ниже xslt, чтобы достичь желаемого значения:

<xsl:stylesheet version="1.0" 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
 xmlns:ws="http://ws.abc.com/"> 
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="*">
  <xsl:element name="ws:{local-name(.)}"
       namespace="http://ws.abc.com/">
    <xsl:apply-templates />
  </xsl:element>
 </xsl:template>

</xsl:stylesheet> 

Но я не могу сгенерировать фактический запрос, который мне требуется:

<ws:gdspCreateVpnNumberList xmlns:ws="http://ws.abc.com/">
    <numberListName>SampleList105</ws:numberListName>
    <numberListDesc>Desc</ws:numberListDesc>
    <selectedCustomerId>200</ws:selectedCustomerId>
    <numbersList>
    <number>21</ws:number>
   </numbersList>
</ws:gdspCreateVpnNumberList>

Вывод:

        <gdspCreateVpnNumberListResponse xmlns:msgns="http://ws.abc.com/" xmlns="http://ws.abc.com/">
            <return xmlns="">
                <returnCode>
                    <majorReturnCode>100</majorReturnCode>
                    <minorReturnCode>7042</minorReturnCode>
                </returnCode>
            </return>
        </gdspCreateVpnNumberListResponse>

Очень ценю вашу помощь в этом ...

С уважением, Анкит

1 Ответ

0 голосов
/ 15 марта 2012

Ваш запрошенный вывод кажется очень странным со всеми элементами, кроме первого, находящегося в пространстве без имен, но это генерирует:

результат:

<ws:gdspCreateVpnNumberList xmlns:ws="http://ws.abc.com/">
   <numberListName>SampleList105</numberListName>
   <numberListDesc>Desc</numberListDesc>
   <selectedCustomerId>200</selectedCustomerId>
   <numbersList>
      <number>21</number>
   </numbersList>
</ws:gdspCreateVpnNumberList>

XSL:

<xsl:stylesheet version="1.0" 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
 xmlns:ws="http://ws.abc.com/"> 
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:template match="/*">
 <xsl:element name="ws:{local-name(.)}"
          namespace="http://ws.abc.com/">
  <xsl:apply-templates />
 </xsl:element>
</xsl:template>
<xsl:template match="*">
 <xsl:element name="{local-name(.)}">
  <xsl:apply-templates />
 </xsl:element>
</xsl:template>

</xsl:stylesheet> 
...