I have the following xml
<?xml version="1.0" encoding="utf-8"?> <Root> <Number>2</Number> <Vehicle> <V4Code>PP03340105</V4Code> <SourceCode>PP03340105</SourceCode> <DRCCode>PP03340105</DRCCode> <OptionalCode1>ANDREA WILLIAM|DWIGHT ROBINSON|04</OptionalCode1> </Vehicle> </Root>
Trying to split with the method given below
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:template match="text()" name="split"> <xsl:param name="pText" select="Root/OptionalCode1"/> <xsl:if test="string-length($pText)"> <xsl:if test="not($pText=.)"> <br /> </xsl:if> <xsl:element name ="Name1"> <xsl:value-of select= "substring-before(concat($pText,'|'),'|')"/> </xsl:element> <xsl:call-template name="split"> <xsl:with-param name="pText" select= "substring-after($pText, '|')"/> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet>
output is just this :
Anyhelp is much appreciated please.I am not sure in what line i am making mistake. Since i am new to this xslt, not sure how to find the line in which i am making mistake too.
Output should be
<Root> <List1>Andrea William</List1> <List2>Dwight Robinson</List2> </Root>
No comments:
Post a Comment