<xsl:output> and 'name' attribute

Here should go questions about transforming XML with XSLT and FOP.
coupes
Posts: 12
Joined: Tue Jun 14, 2005 6:40 pm

<xsl:output> and 'name' attribute

Post by coupes »

Hi,

This isn't much of an issue as it doesn't really cause any problem for me at the moment. Anyhow, whenever I tried to parse my xml files, Oxygen came up with an error saying I did not define the 'name' attribute of the 'output' element. Maybe I'm mistaking, but I though there was no such thing as a name attribute in the output element. However, as soon as I put a name attribue, the error was gone and the file parsed correctly.

What's the deal with that ?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

If you are editing a XSLT stylesheet the <xsl:output> element where xsl is a prefix for the XSLT namespace http://www.w3.org/1999/XSL/Transform does not have an attribute name. If you are editing other type of XML document probably the schema of that document specifies that the name attribute is required. Please post small samples of the document and schema used to validate that document so we can get the same error.

Best regards,
Sorin
coupes
Posts: 12
Joined: Tue Jun 14, 2005 6:40 pm

Post by coupes »

Hi, thanks for your reply.

I'm simply editing an xslt stylesheet (with the xsl namespace), but I'm using <result-document> to generate multiple html pages.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: <xsl:output> and 'name' attribute

Post by sorin_ristache »

Hello,
coupes wrote:whenever I tried to parse my xml files, Oxygen came up with an error saying I did not define the 'name' attribute of the 'output' element.
What do you mean by parsing an XML file ? When you are editing an XSLT 2.0 stylesheet the xsl:output element is not necessary to have a name attribute. The following simple stylesheet is valid and applied on any XML document generates a file C:\temp\output.html that can be viewed in any Web browser no matter where is located the XML input document and the XSLT 2.0 stylesheet:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output encoding="UTF-8"/>

<xsl:template match="/">
<xsl:result-document href="file:/C:/temp/output.html">
<html>
<head>
<title>Simple HTML document</title>
</head>
<body>
<p>The <b>xsl:output</b> element has no <b>name</b> attribute.</p>
</body>
</html>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>
Best regards,
Sorin
coupes
Posts: 12
Joined: Tue Jun 14, 2005 6:40 pm

Post by coupes »

I found out what the problem was... :oops:

I had a format attribute specified for some of my <xsl:result-document> elements. So I had to have the name attribute.

This also helped me solve another problem I had, where my html output was indented despite the indent="no" I had specified in my <xsl:output>. Turns out I hadn't specified a format attribute for this particular <xsl:result-document> element.

Thanks again sorin.
Post Reply