If I've got data that looks like
|Family|Tom|Mary|Bobby|Suzie|
|Family|Mark|Nancy|Alex|Mary|
|Family|Don|Patty|Brian|Jo
And I have a transform which looks like this
<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">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<root>
<xsl:if
test="unparsed-text-available('file://BNEWMAN/Users/bnewman/Desktop/test.txt')">
<xsl:variable name="datafile"
select="unparsed-text('file://BNEWMAN/Users/bnewman/Desktop/test.txt')"/>
<xsl:for-each
select="tokenize(normalize-space($datafile), '[|]Family')">
<rootpart>
<xsl:for-each
select="tokenize(.,'[|]')">
<xsl:choose>
<xsl:when
test=".[position()=1]">
<father>
<xsl:value-of select="."/>
</father>
</xsl:when>
<xsl:when
test=".[position()=2]">
<mother>
<xsl:value-of select="."/>
</mother>
</xsl:when>
<xsl:when
test=".[position()=3]">
<child>
<xsl:value-of select="."/>
</child>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</rootpart>
</xsl:for-each>
</xsl:if>
</root>
</xsl:template>
</xsl:stylesheet>
I am expecting to get a result which looks like this
<root xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<rootpart/>
<rootpart>
<father>Tom</father>
<mother>Mary</mother>
<child>Bobby</child>
</rootpart>
<rootpart>
<father>Mark</father>
<mother>Nancy</mother>
<child>Alex</child>
</rootpart>
<rootpart>
<father>Don</father>
<mother>Patty</mother>
<child>Brian</child>
</rootpart>
</root>
But I'm getting results which look like this
<root xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<rootpart/>
<rootpart>
<firstnode>Tom</firstnode>
<firstnode>Mary</firstnode>
<firstnode>Bobby</firstnode>
<firstnode>Suzie</firstnode>
<firstnode> </firstnode>
</rootpart>
<rootpart>
<firstnode>Mark</firstnode>
<firstnode>Nancy</firstnode>
<firstnode>Alex</firstnode>
<firstnode>Mary</firstnode>
<firstnode> </firstnode>
</rootpart>
<rootpart>
<firstnode>Don</firstnode>
<firstnode>Patty</firstnode>
<firstnode>Brian</firstnode>
<firstnode>Jo</firstnode>
</rootpart>
</root>
Can someone help me understand why?
Btw, this is the Altova engine.
(I've been web surfing to figure out how to get Saxon 9 to integrate with
XmlSpy on a Windows machine)
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--