Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with xsl and document( ) command

Status
Not open for further replies.

bennyboy79

Programmer
Dec 4, 2003
1
GB
hi there. ok. here is the problem...

i have a main database xml file that looks like this
<CODE>
<?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
<?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;sort.xsl&quot; ?>
<!DOCTYPE list SYSTEM &quot;maindb.dtd&quot;>
<list>
<taxpayer id=&quot;js&quot; file=&quot;johnsmith.xml&quot;/>
<taxpayer id=&quot;dj&quot; file=&quot;davejones.xml&quot;/>
<taxpayer id=&quot;rt&quot; file=&quot;roberttilley.xml&quot;/>
<taxpayer id=&quot;ec&quot; file=&quot;edchinn.xml&quot;/>
<taxpayer id=&quot;sm&quot; file=&quot;sammorton.xml&quot;/>
<taxpayer id=&quot;pd&quot; file=&quot;philderuyter.xml&quot;/>
<taxpayer id=&quot;ck&quot; file=&quot;chantelleknoetze.xml&quot;/>
<taxpayer id=&quot;bm&quot; file=&quot;benmorton.xml&quot;/>
<taxpayer id=&quot;pp&quot; file=&quot;peterparker.xml&quot;/>
<taxpayer id=&quot;am&quot; file=&quot;alexmoody.xml&quot;/>
</list>
</CODE>

and each taxpayer refers to another external file file as shown, like

<CODE>
<?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
<!DOCTYPE taxpayer SYSTEM &quot;taxpayer.dtd&quot;>
<taxpayer id=&quot;bm&quot; >
<name>
<family>morton</family>
<given>ben</given>
</name>
<address number=&quot;27&quot; postcode=&quot;RH110LN&quot;>
<line1>cherrytree lane</line1>
<line2>filed close</line2>
<city>crawley</city>
</address>
<phone>01293521336</phone>
<email>benmorton@home.com</email>
<income salary=&quot;3000&quot; allowance=&quot;6000&quot;/>
</taxpayer>
</CODE>

now, the xsl file associated with the main database xml file is used to sort the taxpayers names alphabetically and output the result to a new xml file. i just cant seem to get it to see the external files and process the names in them!!!!! its really doing my head in. the sort xsl file looks like this:

<CODE>
<?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
<xsl:stylesheet xmlns:xsl=&quot; version=&quot;1.0&quot;>
<xslutput method=&quot;xml&quot;/>
<xsl:include href=&quot;resultstyle.xsl&quot;/>
<!-- Template for root rule -->
<xsl:template match=&quot;/&quot;>
<!-- call the stylesheet for the resulting table-->
<xsl:call-template name=&quot;resultstyle&quot;/>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match=&quot;list&quot;>
<h1>Sorting taxpayers by name in ascending order</h1>
<!-- Table Header Creation -->
<table border=&quot;1&quot;>
<tr>
<th>Surname</th>
<th>Firstname</th>
</tr>
<xsl:for-each select=&quot;document(@file)//taxpayer/name&quot;>
<xsl:sort order=&quot;ascending&quot; select=&quot;family&quot;/>
<tr>
<td>
<xsl:value-of select=&quot;family&quot;/>
</td>
<td>
<xsl:value-of select=&quot;given&quot;/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
</CODE>

please please can someone help me asap.

thanks alot in advance

bennyboy79
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top