[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: document() loops

Subject: Re: document() loops
From: "Vasu Chakkera" <vasucv@xxxxxxxxxxx>
Date: Thu, 12 Sep 2002 16:09:35 +0000
write to file xslt
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@xxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.