Re: XSL transformer
"R. Bijlsma" <[email protected]> Wed, 06 Aug 2008 12:24:19 +0200
| Newsgroups | gmane.text.xml.xpath.general |
|---|---|
| Message-ID | <[email protected]> |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> <br> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> Amila Liyanaarachchi wrote: <blockquote cite="mid88CCC2A657757A4EBDB4B19CAD978E5927582F2220@CMBEXMBX1.corpnet.ifsworld.com" type="cite"> <meta http-equiv="Content-Type" content="text/html; "> <meta content="MSHTML 6.00.5700.6" name="GENERATOR"> <div><span class="381553411-05082008"><font face="Arial" size="2">Hi,</font></span></div> <div><span class="381553411-05082008"></span> </div> <div><span class="381553411-05082008"><font face="Arial" size="2">I need to perform the following transformation, any help will be appreciated,</font></span></div> <div><span class="381553411-05082008"></span> <br> </div> </blockquote> Hi Amila,<br> <br> Below you find a working xslt. This is assuming that you know beforehand that it is distance and<br> time that you want to have listed. If it should be found from the input which parameters should be listed,<br> please let me know and I will write it for you.<br> <br> Best regards,<br> Rita Bylsma<br> <blockquote cite="mid88CCC2A657757A4EBDB4B19CAD978E5927582F2220@CMBEXMBX1.corpnet.ifsworld.com" type="cite"> <div><span class="381553411-05082008"></span> </div> <div><span class="381553411-05082008"><font face="Arial" size="2">-------- input xml -------------</font></span></div> <div><span class="381553411-05082008"><font face="Arial" size="2"><soapenv:Envelope xmlns:soapenv="<a href="http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap.org/soap/envelope/</a>" xmlns:xsd="<a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a>" xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>"><br> <soapenv:Body><br> <ns1:driveTimeDisResponse soapenv:encodingStyle="<a href="http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap.org/soap/encoding/</a>" xmlns:ns1="<a href="http://routing.soap.geosolutions.be">http://routing.soap.geosolutions.be</a>"><br> <driveTimeDisReturn href="#id0"/><br> </ns1:driveTimeDisResponse><br> <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="<a href="http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap.org/soap/encoding/</a>" xsi:type="ns2:SoapReturnDriveTime" xmlns:soapenc="<a href="http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap.org/soap/encoding/</a>" xmlns:ns2="<a href="http://beans.soap.geosolutions.be">http://beans.soap.geosolutions.be</a>"><br> <errorCode xsi:type="soapenc:string"/><br> <errorMessage xsi:type="soapenc:string"/><br> <routesInfo soapenc:arrayType="ns2:GenRouteInfo[1]" xsi:type="soapenc:Array"><br> <routesInfo href="#id1"/><br> </routesInfo><br> <token xsi:type="soapenc:string">XXX</token><br> </multiRef><br> <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="<a href="http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap.org/soap/encoding/</a>" xsi:type="ns3:GenRouteInfo" xmlns:ns3="<a href="http://beans.soap.geosolutions.be">http://beans.soap.geosolutions.be</a>" xmlns:soapenc="<a href="http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap.org/soap/encoding/</a>"><br> <distance href="#id2"/><br> <time href="#id3"/><br> </multiRef><br> <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="<a href="http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap.org/soap/encoding/</a>" xsi:type="xsd:long" xmlns:soapenc="<a href="http://schemas.xmlsoap.org/soap/encoding/%22%3E73770%3C/multiRef">http://schemas.xmlsoap.org/soap/encoding/">73770</multiRef</a>><br> <multiRef id="id3" soapenc:root="0" soapenv:encodingStyle="<a href="http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap.org/soap/encoding/</a>" xsi:type="xsd:long" xmlns:soapenc="<a href="http://schemas.xmlsoap.org/soap/encoding/%22%3E2884%3C/multiRef">http://schemas.xmlsoap.org/soap/encoding/">2884</multiRef</a>><br> </soapenv:Body><br> </soapenv:Envelope></font></span></div> <div><span class="381553411-05082008"><font face="Arial" size="2">-------------------------------------</font></span></div> <div><span class="381553411-05082008"></span> </div> <div><span class="381553411-05082008"><font face="Arial" size="2">--- expected output ----</font></span></div> <div><span class="381553411-05082008"><font face="Arial" size="2"><AAA></font></span></div> <div><span class="381553411-05082008"><font face="Arial" size="2"><distance>73770<span class="381553411-05082008"><font face="Arial" size="2"></distance></font></span></font></span></div> <div><span class="381553411-05082008"><font face="Arial" size="2"><span class="381553411-05082008"> <div><span class="381553411-05082008"><font face="Arial" size="2"><time>2884<span class="381553411-05082008"><font face="Arial" size="2"></time></font></span></font></span></div> </span></font></span></div> <div><span class="381553411-05082008"><font face="Arial" size="2"></AAA></font></span></div> <div><span class="381553411-05082008"><font face="Arial" size="2">---------------------------------</font></span></div> </blockquote> <?xml version="1.0" encoding="ISO-8859-1"?><br> <br> <br> <xsl:transform version='1.0'<br> xmlns:xsl='<a class="moz-txt-link-freetext" href="http://www.w3.org/1999/XSL/Transform">http://www.w3.org/1999/XSL/Transform</a>'<br> ><br> <br> <xsl:output<br> method="xml"<br> encoding="iso-8859-1"<br> indent="yes"<br> /> <br> <br> <br> <xsl:template match='/'><br> <br> <xsl:variable name='distance-id' select='substring-after(//distance/@href,"#")'/><br> <xsl:variable name='time-id' select='substring-after(//time/@href,"#")'/><br> <br> <xsl:if test='not($distance-id and $time-id)'><br> <xsl:message><br> Oeps, distance and time were not both found.<br> </xsl:message><br> </xsl:if><br> <br> <AAA><br> <distance><xsl:value-of select='//*[@id=$distance-id]'/></distance><br> <time><xsl:value-of select='//*[@id=$time-id]'/></time><br> </AAA><br> <br> </xsl:template><br> <br> </xsl:transform><br> <br> <br> <blockquote cite="mid88CCC2A657757A4EBDB4B19CAD978E5927582F2220@CMBEXMBX1.corpnet.ifsworld.com" type="cite"> <pre>------------------------------------------------------------------------------ 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. </pre> </blockquote> <br> </body> </html>