result-document and atomic values.
Posted: Fri Jul 24, 2009 8:29 pm
Hi
This is my dummy data...
This is my .xsl
My question:
I want to get the values of the <account_num> and <representative> nodes for each company, into the generated files. Using distinct-values, i can get the xsl to create a file for each company.. but if i try something like this..
I get the following error.
F [Saxon-B 9.0.0.6] Axis step child::element(account_num, xs:anyType) cannot be used here: the context item is an atomic value
Any ideas how i can get actual node information instead of atomic values in this context? (i am a noob so that may not sound right).
This is my dummy data...
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<row>
<company>Tree House Int.</company>
<account_num>2823994756</account_num>
<representative>Bob Schafer</representative>
<type>supplier</type>
</row>
<row>
<company>Whatola</company>
<account_num>567123456</account_num>
<representative>Jane Adamms</representative>
<type>manufacturer</type>
</row>
<row>
<company>LKJ Industrial</company>
<account_num>298347987</account_num>
<representative>Tyler Warrent</representative>
<type>recycler</type>
</row>
<row>
<company>D+J Watson Ent.</company>
<account_num>456734</account_num>
<representative>Janet Lerpray</representative>
<type>supplier</type>
</row>
<row>
<company>Whatola</company>
<account_num>1111114</account_num>
<representative>Elouise Peabody</representative>
<type>manufacturer</type>
</row>
</Root>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="distinct-values(//company)">
<xsl:variable name="cmpname" select="." />
<xsl:value-of select="$cmpname" />
<xsl:result-document href="{$cmpname}">
</xsl:result-document>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I want to get the values of the <account_num> and <representative> nodes for each company, into the generated files. Using distinct-values, i can get the xsl to create a file for each company.. but if i try something like this..
Code: Select all
<xsl:result-document href="{$cmpname}">
<xsl:value-of select="../representative"/>
</xsl:result-document>
F [Saxon-B 9.0.0.6] Axis step child::element(account_num, xs:anyType) cannot be used here: the context item is an atomic value
Any ideas how i can get actual node information instead of atomic values in this context? (i am a noob so that may not sound right).