XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 4th, 2003, 02:25 PM
bennyboy79 bennyboy79 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 4 bennyboy79 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 25 m 5 sec
Reputation Power: 0
xsl and document( ) for external files and sorting - help needed

hi there. ok. here is the problem...

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

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

<CODE>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE taxpayer SYSTEM "taxpayer.dtd">
<taxpayer id="bm" >
<name>
<family>morton</family>
<given>ben</given>
</name>
<address number="27" postcode="RH110LN">
<line1>cherrytree lane</line1>
<line2>filed close</line2>
<city>crawley</city>
</address>
<phone>01293521336</phone>
<email>benmorton@home.com</email>
<income salary="3000" allowance="6000"/>
</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="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<xsl:include href="resultstyle.xsl"/>
<!-- Template for root rule -->
<xsl:template match="/">
<!-- call the stylesheet for the resulting table-->
<xsl:call-template name="resultstyle"/>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="list">
<h1>Sorting taxpayers by name in ascending order</h1>
<!-- Table Header Creation -->
<table border="1">
<tr>
<th>Surname</th>
<th>Firstname</th>
</tr>
<xsl:for-each select="document(@file)//taxpayer/name">
<xsl:sort order="ascending" select="family"/>
<tr>
<td>
<xsl:value-of select="family"/>
</td>
<td>
<xsl:value-of select="given"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
</CODE>

please please can someone help me asap.

thanks alot in advance

bennyboy79

Last edited by bennyboy79 : December 5th, 2003 at 10:07 AM.

Reply With Quote
  #2  
Old December 6th, 2003, 10:12 AM
teedee teedee is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 42 teedee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
I hate to break it to you but this code:
Code:
select="document(@file)//taxpayer/name"


... will *never* work using standard XSL. You can't pass an attribute value into an XPATH this way, it isn't supported.

I'm wondering why you need to make life so complicated? It would be so much easier to put all the taxpayers into a single XML file! You wouldn't need to use the document function at all *and* you could perform proper sorting on the data inside the taxpayers XML.

document() is one of those convenient little fucntions that promises more than it can deliver. If your application relies on document() then you're probably doing something wrong

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > xslt and document( ) for external files and sorting


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway