XSL transformer

View: New views
3 Messages — Rating Filter:   Alert me  

XSL transformer

by Amila Liyanaarachchi-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
 
I need to perform the following transformation, any help will be appreciated,
 
 
-------- input xml -------------
<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>
      <ns1:driveTimeDisResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://routing.soap.geosolutions.be">
         <driveTimeDisReturn href="#id0"/>
      </ns1:driveTimeDisResponse>
      <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:SoapReturnDriveTime" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://beans.soap.geosolutions.be">
         <errorCode xsi:type="soapenc:string"/>
         <errorMessage xsi:type="soapenc:string"/>
         <routesInfo soapenc:arrayType="ns2:GenRouteInfo[1]" xsi:type="soapenc:Array">
            <routesInfo href="#id1"/>
         </routesInfo>
         <token xsi:type="soapenc:string">XXX</token>
      </multiRef>
      <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:GenRouteInfo" xmlns:ns3="http://beans.soap.geosolutions.be" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
         <distance href="#id2"/>
         <time href="#id3"/>
      </multiRef>
      <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:long" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">73770</multiRef>
      <multiRef id="id3" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:long" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">2884</multiRef>
   </soapenv:Body>
</soapenv:Envelope>
-------------------------------------
 
--- expected output ----
<AAA>
<distance>73770</distance>
<time>2884</time>
</AAA>
---------------------------------
------------------------------------------------------------------------------

CONFIDENTIALITY AND DISCLAIMER NOTICE

This e-mail, including any attachments, is confidential and intended only for
the addressee. If you are not the intended recipient, please notify us
immediately and delete this e-mail from your system. Any use or disclosure of
the information contained herein is strictly prohibited.


Parent Message unknown Re: XSL transformer

by R. Bijlsma :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Amila Liyanaarachchi wrote:
Hi,
 
I need to perform the following transformation, any help will be appreciated,

    Hi Amila,
        
      Below you find a working xslt. This is assuming that you know beforehand that it is distance and
time that you want to have listed. If it should be found from the input which parameters should be listed,
please let me know and I will write it for you.

   Best regards,
                             Rita Bylsma
 
-------- input xml -------------
<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>
      <ns1:driveTimeDisResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://routing.soap.geosolutions.be">
         <driveTimeDisReturn href="#id0"/>
      </ns1:driveTimeDisResponse>
      <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:SoapReturnDriveTime" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://beans.soap.geosolutions.be">
         <errorCode xsi:type="soapenc:string"/>
         <errorMessage xsi:type="soapenc:string"/>
         <routesInfo soapenc:arrayType="ns2:GenRouteInfo[1]" xsi:type="soapenc:Array">
            <routesInfo href="#id1"/>
         </routesInfo>
         <token xsi:type="soapenc:string">XXX</token>
      </multiRef>
      <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:GenRouteInfo" xmlns:ns3="http://beans.soap.geosolutions.be" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
         <distance href="#id2"/>
         <time href="#id3"/>
      </multiRef>
      <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:long" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">73770</multiRef>
      <multiRef id="id3" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:long" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">2884</multiRef>
   </soapenv:Body>
</soapenv:Envelope>
-------------------------------------
 
--- expected output ----
<AAA>
<distance>73770</distance>
<time>2884</time>
</AAA>
---------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>


<xsl:transform  version='1.0'
   xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
 >

<xsl:output
   method="xml"
   encoding="iso-8859-1"
   indent="yes"
/>


<xsl:template match='/'>
 
  <xsl:variable name='distance-id' select='substring-after(//distance/@href,"#")'/>
  <xsl:variable name='time-id' select='substring-after(//time/@href,"#")'/>

  <xsl:if test='not($distance-id and $time-id)'>
   <xsl:message>
    Oeps, distance and time were not both found.
   </xsl:message>
  </xsl:if>

  <AAA>
   <distance><xsl:value-of select='//*[@id=$distance-id]'/></distance>
   <time><xsl:value-of select='//*[@id=$time-id]'/></time>
  </AAA>

</xsl:template>

</xsl:transform>


------------------------------------------------------------------------------

CONFIDENTIALITY AND DISCLAIMER NOTICE

This e-mail, including any attachments, is confidential and intended only for
the addressee. If you are not the intended recipient, please notify us
immediately and delete this e-mail from your system. Any use or disclosure of
the information contained herein is strictly prohibited.

  


RE: XSL transformer

by Michael Kay-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


This list is provided to allow people to make comments on the XPath 1.0
specification, for the attention of the W3C working groups responsible.

If you want programming help with XSLT and XPath, please use the xsl-list
provided by mulberrytech.com

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: www-xpath-comments-request@...
> [mailto:www-xpath-comments-request@...] On Behalf Of Amila
> Liyanaarachchi
> Sent: 05 August 2008 12:39
> To: www-xpath-comments@...
> Subject: XSL transformer
>
> Hi,
>  
> I need to perform the following transformation, any help will
> be appreciated,
>  
>  
> -------- input xml -------------
> <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>
>       <ns1:driveTimeDisResponse
> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encodin
> g/" xmlns:ns1="http://routing.soap.geosolutions.be">
>          <driveTimeDisReturn href="#id0"/>
>       </ns1:driveTimeDisResponse>
>       <multiRef id="id0" soapenc:root="0"
> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encodin
> g/" xsi:type="ns2:SoapReturnDriveTime"
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:ns2="http://beans.soap.geosolutions.be">
>          <errorCode xsi:type="soapenc:string"/>
>          <errorMessage xsi:type="soapenc:string"/>
>          <routesInfo soapenc:arrayType="ns2:GenRouteInfo[1]"
> xsi:type="soapenc:Array">
>             <routesInfo href="#id1"/>
>          </routesInfo>
>          <token xsi:type="soapenc:string">XXX</token>
>       </multiRef>
>       <multiRef id="id1" soapenc:root="0"
> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encodin
> g/" xsi:type="ns3:GenRouteInfo"
> xmlns:ns3="http://beans.soap.geosolutions.be"
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
>          <distance href="#id2"/>
>          <time href="#id3"/>
>       </multiRef>
>       <multiRef id="id2" soapenc:root="0"
> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encodin
> g/" xsi:type="xsd:long"
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">7377
> 0</multiRef>
>       <multiRef id="id3" soapenc:root="0"
> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encodin
> g/" xsi:type="xsd:long"
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">2884
> </multiRef>
>    </soapenv:Body>
> </soapenv:Envelope>
> -------------------------------------
>  
> --- expected output ----
> <AAA>
> <distance>73770</distance>
> <time>2884</time>
> </AAA>
> ---------------------------------
> --------------------------------------------------------------
> ----------------
>
> CONFIDENTIALITY AND DISCLAIMER NOTICE
>
> This e-mail, including any attachments, is confidential and
> intended only for the addressee. If you are not the intended
> recipient, please notify us immediately and delete this
> e-mail from your system. Any use or disclosure of the
> information contained herein is strictly prohibited.
>
>