[xsl] problem with including external files

Subject: [xsl] problem with including external files
From: "Laura Jenkins" <xsl_list@xxxxxxxxxxx>
Date: Thu, 12 Sep 2002 12:00:55 +0000
HI i have a problem , i cant understand...
i have an xml that has the links to three other xml files

<?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>


My xsl should read this xml and create another xml merging the contents of the xmlfiles that are specified in the xml above


what i want to do is , store all the elements from one of the xmls( all three are identical xmls with data different) into a variable,

then run through this variable (may i call it variable loop ??), create an element with name equals current node-name and insert the data from each of the xmls into this created element where the element name equals the name of the current-element name( from the variable loop)..

example of one of the xml files..

<?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>

the following is what i do.

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:xalan="http://xml.apache.org/xalan"; version="1.0" exclude-result-prefixes="xalan">
<xsl:output method="xml" indent="yes"/>


<xsl:template match="univ-xml-list">
<xsl:variable name="univ-elements">
<xsl:copy-of select="document(//univ-xml[1])/university-records/node()|document(//univ-xml[1])/university-records/@*"/>
</xsl:variable>
<university-records>
<xsl:for-each select="xalan:nodeset($univ-elements)"> **for loop 1**
<xsl:variable name="element-name" select="name(.)"/>
<xsl:element name="{name(.)}">
<xsl:for-each select="document(//univ-xml)//*[name()=$element-name]"> **for loop 2**
<xsl:copy-of select="./*"/> ** LINE1 **
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</university-records>
</xsl:template>
</xsl:stylesheet>


This was my script which i thought would create elements with names(of the nodes in the loop that runs the variable storing all the elements) and insert the contents from all the three xml files.
This is however not working..
In the above code the **LINE1** inside the for loop doesnt seem to have any effect or may be the 2nd **foorloop 2** doesnt have any effect. If however if the **foorloop 2**is taken out of **forloop1** with the hardcoded $element-name ,it shows some result
I do not understand this strange behaviour..
I wud be grateful if some one could explain this behaviour..
or let me know if thiscan be done in any other better way.
Thanks a ton!!!!!




_________________________________________________________________
Join the world?s largest e-mail service with MSN Hotmail. http://www.hotmail.com



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



Current Thread