473,395 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

cocoon and document() function


Hi NG,

I have the following xml-file (simplified):

<?xml version="1.0" encoding="ISO-8859-1"?>
<dir:directory xmlns:dir="http://apache.org/cocoon/directory/2.0">
<dir:file name="cook0002.xml">
</dir:directory>

and the following xsl-file:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dir="http://apache.org/cocoon/directory/2.0">

<xsl:template match="dir:directory">
<xsl:element name="demos">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

<xsl:template match="dir:file">
<xsl:element name="demo">
<xsl:element name="file">
<xsl:value-of select="@name"/>
</xsl:element>
<xsl:element name="symbol">
<xsl:value-of select="document(@name)/document/title"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

the output should be:

<?xml version="1.0" encoding="UTF-16"?>
<demos>
<demo>
<file>cook0002.xml</file>
<symbol>Wiener Schnitzel</symbol>
</demo>
</demos>

It works with Xselerator, but cocoon 2.1 gives me only the
following output:

<?xml version="1.0" encoding="UTF-16"?>
<demos>
<demo>
<file>cook0002.xml</file>
<symbol/>
</demo>
</demos>

Any hints for solving my problem?

Thanx in advance,
Gerald
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 20 '05 #1
2 1503
Gerald Aichholzer <ga**@sbox.tugraz.at> writes:
I have the following xml-file (simplified):

<?xml version="1.0" encoding="ISO-8859-1"?>
<dir:directory xmlns:dir="http://apache.org/cocoon/directory/2.0">
<dir:file name="cook0002.xml">
</dir:directory>
Too simplified. Your dir:file element is not closed.
and the following xsl-file: <snip/> <xsl:value-of select="document(@name)/document/title"/>


This will look for a file called "cook0002.xml" which you don't show
us. If I create that file with these contents in the same directory as
my xslt file:
<document>
<title>Wiener Schnitzel</title>
</document>

then with both sablotron and xsltproc I get the result you desire.

Perhaps cocoon can't find the file cook0002.xml. In that case
xsltproc generates an empty tag and sablotron throws an error. Either
is allowed according to the W3C XSLT 1.0 Rec.

Ben

--
Ben Edgington
Mail to the address above is discarded.
Mail to ben at that address might be read.
http://www.edginet.org/
Jul 20 '05 #2
On 12 May 2004 15:50:07 +0100, Ben Edgington <us****@edginet.org> wrote:
Gerald Aichholzer <ga**@sbox.tugraz.at> writes:
I have the following xml-file (simplified):

<?xml version="1.0" encoding="ISO-8859-1"?>
<dir:directory xmlns:dir="http://apache.org/cocoon/directory/2.0">
<dir:file name="cook0002.xml">
</dir:directory>


Too simplified. Your dir:file element is not closed.
and the following xsl-file:

<snip/>
<xsl:value-of select="document(@name)/document/title"/>


This will look for a file called "cook0002.xml" which you don't show
us. If I create that file with these contents in the same directory as
my xslt file:
<document>
<title>Wiener Schnitzel</title>
</document>

then with both sablotron and xsltproc I get the result you desire.

Perhaps cocoon can't find the file cook0002.xml. In that case
xsltproc generates an empty tag and sablotron throws an error. Either
is allowed according to the W3C XSLT 1.0 Rec.


That's exactly the problem - the file looks like in your example.
Cocoon's default path for looking for "cook0002.xml" wasn't where
I have expected it to be.

Anyway I have found out in the FAQ that it is not recommended to
use the document() function with cocoon. Right now I'm trying to
find out more about Xinclude and Xpointer which is suggested as
an alternative.

thanx,
Gerald
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: MicFra | last post by:
hi, i got a little problem with pdf-serializing after updating from cocoon 2.1.2 to 2.1.4. following scenario: - using serializer org.apache.cocoon.serialization.FOPSerializer, with name...
0
by: Adam | last post by:
Hi! I'm trying to do a login form in cocoon. Login data are taken from MySQL, but before the data are checked cocoon throws such an error: org.apache.cocoon.ResourceNotFoundException: Resource...
0
by: Pat | last post by:
I am having a problem with large pdf files begin generated by fop from cocoon. There appears to be a file size limitation on the generated pdf files. When we run a small document everything works...
1
by: Jawahar | last post by:
Hi All.. Currently in our application, we are using Serlvet as Controller,Jsp to View,BusinessLogic in EJB. We planned to implement Cocoon frame work in our existing application. Is this...
6
by: Jeremy | last post by:
My requirements are very simple: When a user browses to an XML document, the server should parse the document, apply its stylesheet, and spit the HTML at the client. Apache Cocoon is a slow,...
0
by: wai | last post by:
hi all, i running cocoon 2.1.1 with websphere 5, i have a problem related to xsp cinclude. everything after my first cinclude statement, it become bank. i been tested the cocoon cinclude...
0
by: Gerald Aichholzer | last post by:
Hi NG, I'm trying to process the following document using cocoon's XInclude-transformer: <demos> <demo> <dir>demo20040429</dir> <date>11.05.04 10:01</date> <xi:include parse="xml"
0
by: Hugh Sparks | last post by:
If I configure and use two different fragment extractors on the same XML document, how can I write xslt template match patterns that distinguish which elements these fragments replaced? Details:...
2
by: rozwel | last post by:
Hi, I'm currently starting a CMS project based on XML-related technologies and I want to use an XML framework as the basis of my architecture. I found two open source project that could fit my...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.