<xsl:template match="/">
<articles>
<xsl:apply-templates/>
</articles>
</xsl:template>
<xsl:template match="article">
<article>
<xsl:value-of select="title"/>
</article>
</xsl:template>
On 11/1/06, J.D. Williams <[EMAIL PROTECTED]> wrote:
I would like to be able to drop valid xml files into a directory and
have them appear automagically in a menu, with the ability to transform
the title of the article in the file into the text of a link if I want.
I get the XPathDirectory generator to work with the following pipeline
matcher.
<map:match pattern="articles/*">
<map:generate type="xpathdirectory" src=""
<map:parameter name="xpath" value="title"/>
<map:parameter name="xmlFiles" value="\.x.*$"/>
</map:generate>
<map:serialize type="xml"/>
</map:match>
The above matcher produces the following output.
<?xml version="1.0" encoding="ISO-8859-1"?>
<dir:directory xmlns:dir=" http://apache.org/cocoon/directory/2.0"
name="articles" lastModified="1162301516000" date="31/10/06 07:31"
size="4096" sort="name" reverse="false" requested="true">
<dir:file name="article1.xml" lastModified="1162312230000"
date="31/10/06 10:30" size="136">
<dir:xpath query="title">
<title>Article title</title>
</dir:xpath>
</dir:file>
</dir:directory>
So far, so good.
However, I would like to transform the XML so I can do other things with
it, such as a quick and dirty dynamic HTML menu or aggregate into
another web page as XML and subsequently transform the title elements
into links. I have attempted the following.
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="article">
<xsl:value-of select="title"/>
</xsl:template>
When I add this XSL to the matcher, still serializing as XML I get this
result (when viewing the source).
<?xml version="1.0" encoding="ISO-8859-1"?>Article title
Which looks OK, but Firefox complains with the following error.
XML Parsing Error: syntax error
Location: http://localhost:8080/sandbox/articles/
Line Number 1, Column 44:<?xml version="1.0"
encoding="ISO-8859-1"?>Article title
-------------------------------------------^
Why is it encoded as ISO-8859-1? Everything in my sitemap says UTF-8.
This happens regardless of the charset I specify in Firefox. Amaya also
complains.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]