This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: document() loops


David, The following is the code and the explanation of my problem
the code..

main xml.
<?xml version="1.0"?>
<univ-xml-list>
<univ-xml>univ1.xml</univ-xml>
<univ-xml>univ2.xml</univ-xml>
<univ-xml>univ3.xml</univ-xml>
</univ-xml-list>

Xsl..

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xalan="http://xml.apache.org/xalan"; xmlns:write-to-file="org.apache.xalan.xslt.extensions.Redirect"
extension-element-prefixes="write-to-file xalan" version="1.0">
<xsl:key match="*" use="descendent" name="all-nodes"/>
<xsl:template match="univ-xml-list">
<xsl:for-each select="document(univ-xml[1])">
<basic>
<first>
<xsl:for-each select="document(univ-xml[2])">
<xsl:copy-of select="*"/>
</xsl:for-each>
</first>
<xsl:copy-of select="*"/>
</basic>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

univ1.xml..

**********************************
<?xml version="1.0"?>
<university-records>
<univ-ids>
<univ id = "KSU">
<name>Kansas State University</name>
<location>Kansas</location>
</univ>
<univ id = "FAU">
<name>Florida Atlantic University</name>
<location>Florida</location>
</univ>
<univ id = "MSU">
<name> Mississipi State University</name>
<location> Mississipi </location>
</univ>
<univ id = "OSU">
<name>Ohio State University</name>
<location> Ohio </location>
</univ>
</univ-ids>
<university-results>
<university univ-id = "KSU">100%</university>
<university univ-id = "MSU">90%</university>
<university univ-id = "FAU">80%</university>
</university-results>
</university-records>

**********************************

univ2.xml

**********************************
<?xml version="1.0"?>
<university-records>
<univ-ids>
<univ id = "OSU">
<name> Ohio State University</name>
<location> Ohio </location>
</univ>
<univ id = "WSU">
<name> Wisconsin state University</name>
<location> Wisconsin </location>
</univ>
<univ id = "RPI">
<name> Rensellar polytechnic Institute </name>
<location> New Jersey </location>
</univ>
<univ id = "MSU">
<name> Mississipi State University</name>
<location> Mississipi </location>
</univ>
</univ-ids>
<university-results>
<university univ-id = "OSU">70%</university>
<university univ-id = "WSU">100%</university>
<university univ-id = "RPI">100%</university>
</university-results>
</university-records>
**********************************

univ3.xsl
**********************************
<?xml version="1.0"?>
<university-records>
<univ-ids>
<univ id = "NSU">
<name> Newyork State University</name>
<location> Newyork </location>
</univ>
<univ id = "BU">
<name> Belmont University</name>
<location> Belmont </location>
</univ>
<univ id = "WSU">
<name>Wisconsin state University</name>
<location> Wisconsin </location>
</univ>
<univ id = "BCM">
<name> Berklee College of Music</name>
<location> Berklee </location>
</univ>
</univ-ids>
<university-results>
<university univ-id = "NU">70%</university>
<university univ-id = "BU">60%</university>
<university univ-id = "BCM">100%</university>
</university-results>
</university-records>

**************************************

what i want is to read from the mainxml the locations of the xml files,
and merge them into one xml in such a way that the it has the same structure as individual xmls and the elements gets inserted into corresponding parent elements..

example output file..

<?xml version="1.0"?>
<university-records>
<univ-ids>
<univ id = "NSU">
<name> Newyork State University</name>
<location> Newyork </location>
</univ>
<univ id = "BU">
<name> Belmont University</name>
<location> Belmont </location>
</univ>
<univ id = "WSU">
<name>Wisconsin state University</name>
<location> Wisconsin </location>
</univ>
<univ id = "BCM">
<name> Berklee College of Music</name>
<location> Berklee </location>
</univ>
<univ id = "KSU">
<name>Kansas State University</name>
<location>Kansas</location>
</univ>
<univ id = "FAU">
<name>Florida Atlantic University</name>
<location>Florida</location>
</univ>
<univ id = "OSU">
<name>Ohio State University</name>
<location> Ohio </location>
</univ>
<univ id = "RPI">
<name> Rensellar polytechnic Institute </name>
<location> New Jersey </location>
</univ>
<univ id = "MSU">
<name> Mississipi State University</name>
<location> Mississipi </location>
</univ>
</univ-ids>
<university-results>
<university univ-id = "NU">70%</university>
<university univ-id = "BU">60%</university>
<university univ-id = "BCM">100%</university>
<university univ-id = "OSU">70%</university>
<university univ-id = "WSU">100%</university>
<university univ-id = "RPI">100%</university>
<university univ-id = "KSU">100%</university>
<university univ-id = "MSU">90%</university>
<university univ-id = "FAU">80%</university>

</university-results>
</university-records>

I cant get this going. This may be a simple task..

any suggestions will be deeply appreciated

From: David Carlisle <davidc@nag.co.uk>
Reply-To: xsl-list@lists.mulberrytech.com
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] document() loops
Date: Thu, 12 Sep 2002 16:18:22 +0100

> Can someone suggest me a way to do this?

your sketch looked valid so presumably the error is in the details of
your code, so you'll need to post a small example.

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]