|
Subject: Re: [xsl] unparsed-text and nodes by position From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx> Date: Fri, 25 Dec 2009 15:14:57 +0100 |
1. empty (or whitespace-only) elements 2. everything seems to be position()=1
ad 1. This is because if you split '|a|b|c|' at '|', you will get five (!) elements, the first and last being empty. You should process the input so that your inner tokenizer encounters strings such as 'a|b|c'.
<xsl:template match="/">
<root>
<xsl:if test="unparsed-text-available('test.txt', 'ISO-8859-1')">
<xsl:variable name="datafile" select="unparsed-text('test.txt', 'ISO-8859-1')" as="xs:string"/>
<xsl:for-each select="tokenize(normalize-space($datafile), '[\s*\r\n]+')">
<rootpart>
<xsl:variable name="line"
select="tokenize(
replace(., '^[|]Family[|](.+?)[|]?\s*$', '$1'),
'[|]'
)"
as="xs:string*" />
<father>
<xsl:value-of select="$line[1]"/>
</father>
<mother>
<xsl:value-of select="$line[2]"/>
</mother>
<xsl:for-each select="$line[position() gt 2]">
<child>
<xsl:value-of select="."/>
</child>
</xsl:for-each>
</rootpart>
</xsl:for-each>
</xsl:if>
</root>
</xsl:template>| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] unparsed-text and nodes by po, Brian Newman | Thread | Re: [xsl] unparsed-text and nodes b, Imsieke, Gerrit, le- |
| [xsl] Re: Merging two XBEL files, List Owner | Date | Re: [xsl] unparsed-text and nodes b, Imsieke, Gerrit, le- |
| Month |