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(_at_)gmail(_dot_)com>:
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(_at_)stanjasele(_dot_)ch> 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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--
****************************
stefan hunziker
kanalweg 10
ch-3315 bätterkinden
tel +41 32 665 17 76
mob +41 79 455 30 62
email stefan(_at_)stanjasele(_dot_)ch
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--