xsl-list
[Top] [All Lists]

Re: [xsl] Add namespaces to a soap xml output

2006-09-22 03:49:58


I  need to add one namespaces to all node and remove all tag that not 
contains any data from a soap envolpe request :

It seems that you don't want to add a namespace, just change the prefix
for the namespace from the default (no prefix) to cup:
Which is slightly odd as it makes no difference to any namespace aware
system which prefix is used, but anyway, something like this:


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 xmlns:cup="some.url">

<xsl:strip-space elements="*"/>
<xsl:output indent="yes"/>
<!--
most stuff you want to copy:
-->
<xsl:template match="*">
 <xsl:copy>
  <xsl:copy-of select="@*"/>
   <xsl:apply-templates/>
 </xsl:copy>
</xsl:template>

<!--
stuff in cup namespace you want to prefix (why?)
-->

<xsl:template match="cup:*">
 <xsl:element name="cup:{local-name()}">
  <xsl:copy-of select="@*"/>
   <xsl:apply-templates/>
 </xsl:element>
</xsl:template>

<!--
zap empty stuff
-->

<xsl:template match="*[not(node())]" priority="2"/>

</xsl:stylesheet>



$ saxon cup.xml cup.xsl
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
   <soapenv:Body>
      <cup:RICHIESTA_INFORMAZIONI_ASSISTITO xmlns:cup="some.url" 
DataOra="200603072355" idCup="150103" idOperatore="df">
         <cup:ASSISTITO>
            <cup:CodFiscale>CRDLCN73L04F839J</cup:CodFiscale>
         </cup:ASSISTITO>
      </cup:RICHIESTA_INFORMAZIONI_ASSISTITO>
   </soapenv:Body>
</soapenv:Envelope>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>