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

Re: fileoutput

Subject: Re: fileoutput
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Mon, 18 Mar 2002 10:57:09 -0800
file schools.xml
hi,

try:

<xsl:variable name = "schools" select ="document('schools.xml')/schools/school"/>

or:

<xsl:for-each select="$schools/schools/school">

or, perhaps cleaner:

<xsl:apply-templates select="$schools/schools/school">
(and do your redirect:write in the school template match)


you need to loop on the 'school' node.


You also need to set xsl:output to text if you want to output text (default is xml).

-Rob


Laura Jenkins wrote:



hi here is a problem i have :


i have an xml file schools.xml
--file schools.xml ---
<Schools>
<school>cal</school>
<school>london</school>
<school>delhi</school>
</schools>

--------------------------------------
my objective is to output each of the school names is a a different file called 'schoolname'-school.txt ( example delhi-school.txt)
and xsl file goes..


<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
               xmlns:xalan="http://xml.apache.org/xslt"
               xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
               extension-element-prefixes="redirect"
               version="1.0">
<xsl:variable name = "schools" select ="document('schools.xml')"/>
<xsl:template match="/">
<xsl:for-each select="$schools">
<xsl:variable name="sc" select="."/>
<xsl:variable name="file" select="concat($sc,'-school','.txt')"/>

<redirect:write select="$file">
<!--
i want to output each time to a file called schoolname-school.txt (example delhi-school.txt)
-->
<xsl:value-of select="$sc"/>
</redirect:write>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>



and there is another XML file against which i run this xsl.


The above code doesnt work!! obviously because of some problem which i am unable to understand. My questions:

1.can someone please tell me where i am going wrong ??
2.Id i have a secondary document imported to my XSL file,
can i get to their children by expression $DocumentName/child??
laura

_________________________________________________________________
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





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.