Skip to content

Instantly share code, notes, and snippets.

@bhdrkn
Created December 26, 2014 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhdrkn/84a4a956b300987719f6 to your computer and use it in GitHub Desktop.
Save bhdrkn/84a4a956b300987719f6 to your computer and use it in GitHub Desktop.
XSLT Tokenize Example
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://v1.helloworld.bahadirakin.com/"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
exclude-result-prefixes="ns0 xs">
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v1="http://v1.helloworld.bahadirakin.com/">
<soapenv:Header />
<soapenv:Body>
<sayHello xmlns="http://v2.helloworld.bahadirakin.com/"
xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:attribute name="xsi:schemaLocation"
namespace="http://www.w3.org/2001/XMLSchema-instance"></xsl:attribute>
<xsl:for-each select="soapenv:Envelope/soapenv:Body/ns0:sayHello">
<xsl:variable name="var1_resultof_cast"
select="string(*[local-name()='request' and namespace-uri()='']/*[local-name()='fullName' and namespace-uri()=''])" />
<xsl:variable name="tokenizedList" select="tokenize($var1_resultof_cast,'\s+')"/>
<request xmlns="">
<xsl:for-each select="$tokenizedList">
<name><xsl:value-of select="."/></name>
</xsl:for-each>
</request>
</xsl:for-each>
</sayHello>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment