Subject: Re: [xsl] document tree fragments From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sat, 11 Oct 2008 08:37:20 -0400 |
I have succeeded, but with two problems. Firstly, I am unable to separately specify the directory path of the files. Here is my "base" xml file's content:
<docs path="jb"> <doc filename="jb/wine1.xml" /> <doc filename="jb/wine2.xml" /> <doc filename="jb/wine3.xml" /> ... </docs>
Note that I have provided the directory path within the @filename attribute, but I would prefer to retrieve it from the @path attribute.
<xsl:template match="/docs">
<xsl:variable name="thePath" select="@path" />
<xsl:variable name="theWines" select="document(doc/@filename)/wine" />
...
Is there a way to use my $thePath variable, instead of including the directory path inside the @filename attribute? I tried to concatenate, but without success.
I want to deal with all my xml files together, rather than using a for-each loop, because of several aggregate processes that I want to apply.
Secondly, I'm not sure I fully understand what my $theWines variable now contains. I believe it is a collection of tree fragments--i.e. there's no single top-most node, is that right? Or is there an implicit / (document) node?
The reason I ask is because I have some templates that rely on processing the preceding axis, and whereas my templates work fine for my < wines > xml file, they do not produce the anticipated results when using my $theWines variable.
<xsl:variable name="countries" select="$wines/wine/countries/country"/> <table> <xsl:for-each select="$countries"> <xsl:sort select="name"/> <!--create a list when encountering the first of them all--> <xsl:if test="generate-id(.)= generate-id($countries[name=current()/name][1])"> <xsl:variable name="this-country" select="$countries[name=current()/name]"/> <tr> <td> <xsl:value-of select="name"/> <xsl:value-of select="count($this-country)"/> ...
Do I need to wrap the sequence of tree fragments in my $theWines variable inside a node?
-- Upcoming XSLT/XSL-FO hands-on courses: Wellington, NZ 2009-01 Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video sample lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg Video course overview: http://www.youtube.com/watch?v=VTiodiij6gE G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] document tree fragments, Joe Barwell | Thread | Re: [xsl] document tree fragments, Joe Barwell |
[xsl] document tree fragments, Joe Barwell | Date | [xsl] Re:Excluding a complete branc, Fraser Goffin |
Month |