Skip to content

Instantly share code, notes, and snippets.

@62mkv
Last active September 7, 2020 11:55
Show Gist options
  • Save 62mkv/3f1aba5c493a3bdebf30284138006cf1 to your computer and use it in GitHub Desktop.
Save 62mkv/3f1aba5c493a3bdebf30284138006cf1 to your computer and use it in GitHub Desktop.
XLST transformation example

How to extract names and values of parameters from a collection inside XML document

Use Altova XMLSpy. The XLST template example given:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" exclude-result-prefixes="xs fn xsl"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns="http://xlogics.eu/blackbox">
	<!--output format close to xquery-->
	<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes"/>
<xsl:template match="/SOAP-ENV:Envelope/SOAP-ENV:Body/tns:PrintParcelRequest/tns:InputParameters">
  <html>
  <body>
  <h2>Input parameters</h2>
  <table border="1">
    <tr bgcolor="#9acd32">
      <th>Name</th>
      <th>Value</th>
    </tr>
    <xsl:for-each select="tns:ShippingParameter">
    <tr>
      <td><xsl:value-of select="tns:Name"/></td>
      <td><xsl:value-of select="tns:Value"/></td>
    </tr>
    </xsl:for-each>
  </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

Open XML document, open XSL document. Press F10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment