[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: document() loops
Actually the question in the previous thread was a bit different.and i was
able to solve it.The previous case was i was using one of the XMLs as main
XML and passing the other xml files as parameters.. that was working fine.
But then the decision changed to have one xml file with all the xml file
locations as child elements like..
**** mainxml.xml**** <?xml version="1.0"?> <!-- all the below xml files( univ1.xml.. etc are in the same directory as mainxml.xml --> <univ-xml-list> <univ-xml>univ1.xml</univ-xml> <univ-xml>univ2.xml</univ-xml> <univ-xml>univ3.xml</univ-xml> </univ-xml-list> and the xsl should now go through each of the univ xmls and merge them. What I thot of doing was first go through one of the xmls( the first one for example ) and construct the elements. <xsl:for-each select="document(/univ-xml-list/univ-xml[1])"> <xsl:variable name = "element-name" select="name(.)"/> <xsl:element name="$element-name">
now the next thing what i want to do is .. run a for-each against the mainxml.xml and plug in the element data into the above created element "where" the element name equals the name of the element from the first for-loop that is.. <xsl:for-each select="document(/univ-xml-list/univ-xml[1])"> <xsl:variable name = "element-name" select="name(.)"/> <xsl:element name="$element-name"> <xsl:for-each select="document(/univ-xml-list/univ-xml)/university-records"> <xsl:copy-of select="*[name(.) = $element-name]"/> </xsl:for-each> </xsl:element> </xsl:for-each> my intention above was to fill in the data elements from all the xml files specified in the mainxml.xml into the element created using the first xml( all xmls will have same structure) But this does not work.. one of the univ xmls is as follows <?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-ids> <university-results> <university univ-id = "NSU">70%</university> <university univ-id = "BU">60%</university> </university-results> </university-records> What i noticed was.. When the for-each is processing one document(), it is not able to process any other document.. and also fails to recognize the elements from the mainxml. I do not know if there is any other way of doing this? Thanks From: David Carlisle <davidc@xxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: document() loops Date: Thu, 12 Sep 2002 17:41:00 +0100 _________________________________________________________________ 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|