[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: accessing multiple xml documents from within one
no, reportDef.xml is not output, but another input, the definition of the resulting report. The output would be a list, in csv format it would look like this: Book title,# pages Hamlet,120 The Perfume,230 Regards, Stefan 2009/1/16 Ganesh Babu N <nbabuganesh@xxxxxxxxx>: > As per my understanding the input is books.xml and output is reportDef.xml. > > You have to write the templates matching books.xml and wrap the > content with the reporDef elements/attributes. > > If you have multiple XML files as input you should use collection() of xslt2 > > Regards, > Ganesh > > > On Fri, Jan 16, 2009 at 4:38 AM, Stefan Hunziker <stefan@xxxxxxxxxxxxx> wrote: >> hi >> >> In my main books.xml document being processed I have a number of >> books, as follows: >> >> <books> >> <book> >> <title>Hamlet</title> >> <author>Shakespeare</author> >> <publisher>Peares</publisher> >> <pagecount>120</pagecount> >> <weight>500g</weight> >> </book> >> <book> >> <title>The Perfume</title> >> <author>Sueskind</author> >> <publisher>ABC</publisher> >> <pagecount>230</pagecount> >> <weight>256g</weight> >> </book> >> </books> >> >> in a second reportDef.xml I want to define a report list, as follows: >> >> <reportDef> >> <col title="Book title" field="title" type="text"/> >> <col title="# pages" field="pagecount" type="number"/> >> </reportDef> >> >> >> Now, with xsl I like to generate a report. Until now it looks like: >> >> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> >> <xsl:output method="text" indent="no" encoding="ISO-8859-1"/> >> <xsl:variable name="reportDef" select="document('reportDef.xml')"/> >> >> <xsl:template match="books"> >> <xsl:apply-templates select="$reportDef" mode="header"/>
 >> <xsl:apply-templates select="book"/> >> </xsl:template> >> >> <xsl:template match="book"> >> <xsl:apply-templates select="$reportDef" mode="data"/>
 >> </xsl:template> >> >> <xsl:template match="col" mode="header"> >> <xsl:value-of select="@title"/>; <!-- this one is no problem--> >> </xsl:template> >> >> <xsl:template match="col" mode="data"> >> <xsl:variable name="fieldname" select="@field"/>; >> <!-- here I want to print the book property $fieldname, but I can't >> access the main xml books --> >> </xsl:template> >> </xsl:stylesheet> >> >> >> The problem is, that I don't see the books.xml from within the >> reportDef templates (<xsl:template match="col" mode="data">). Also >> when I pass the book node by param to the template there is no content >> in this node! >> >> I would be very happy if anybody could give me a hint >> >> Thanks very much >> Stefan > > -- **************************** stefan hunziker kanalweg 10 ch-3315 bdtterkinden tel +41 32 665 17 76 mob +41 79 455 30 62 email stefan@xxxxxxxxxxxxx
|
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
|