Page 1 of 1

XHTML transform gets unwnated attribute injected

Posted: Mon Mar 23, 2015 1:42 pm
by amix
The following (example only, don't try to find any sense in it) XHTML:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Document Title</title>
</head>
<body>
<h3>Contents</h3>
<p><a href="#part1">Heading 2</a><br />
</p>
<hr />
<p><a id="part1" name="part1"></a></p>
<h2 id="ud74ab77b-6177-4a28-a22b-4a6a58a5c0f3">Heading 2</h2>
<p>para2</p>
<p>para 1</p>
</body>
</html>
when processed with the following XSL-T (no sense in it either, just an example):

Code: Select all

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

<xsl:output
method="xhtml"
indent="yes"
encoding="UTF-8"
doctype-public="//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
cdata-section-elements="script style"/>

<xsl:strip-space elements="*"/>

<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="//a/@href">
<xsl:value-of select="generate-id()"/>
</xsl:template>

</xsl:stylesheet>
leads to the following error:
Saxon-EE 9.5.1.5
fatal:
XTDE0410: An attribute node (shape) cannot be created after a child of the containing element. Most recent element start tag was output at line 19 of module test.xsl
URL: http://www.w3.org/TR/xslt20/#err-XTDE0410
When I checked the document-type/framework configuration I realized, that XHTML is being associated with XHTML5/ePub3. I am confused.
But I am also not understanding, why this happens at all? Why does the processor add attributes, that are not being in either of the two documents. It must have to do with the identity-copy, but this never ever happened to me before.

My questions therefore would be:
  • Why is XHTML being bound to Epub3 as a default?
  • How can I configure Oxygen in a way, that it uses the document-type I have declared in the source-document?
  • How can I make sure, that XHTML5/ePub3 still gets validated with the right spec if I change the default?
  • Why does an identity-copy inject attributes, that, while present in the schema, are not in either source document? And why does it only inject the "shape" attribute, but no others?
Thank you,
Andreas

Re: XHTML transform gets unwnated attribute injected

Posted: Mon Mar 23, 2015 2:29 pm
by adrian
Hi,
Why is XHTML being bound to Epub3 as a default?
XHTML isn't always bound to XHTML5/ePub3, but it may depend on the version of Oxygen. What version are you using (Help > About)?
The general rule is that it gets bound to XHTML 1.0 or XHTML5(ePub3 schemas) depending on the DOCTYPE. If it is the simple <!DOCTYPE html> it gets bound to XHTML 5. It has a public or system ID, it uses that.
In your case, it shouldn't be bound to XHTML5. Switch to the XHTML document and look in the Properties view (Window > Show View > Properties) at the value of "Content completion". It should point to the xhtml1-strict.dtd from the xhtml framework resolved from the public/system ID.
How can I configure Oxygen in a way, that it uses the document-type I have declared in the source-document?
How can I make sure, that XHTML5/ePub3 still gets validated with the right spec if I change the default?
In both cases it should already work with the default. Check the Properties view as instructed above for each case.
Why does an identity-copy inject attributes, that, while present in the schema, are not in either source document? And why does it only inject the "shape" attribute, but no others?
This depends on a setting from the XSL processor Advanced options from the transformation scenario configuration (Document -> Transformation -> "Configure Transformation Scenario(s)", Edit). Press the "Advanced options" button (cogwheel icon) on the right of the Transformer combo and uncheck the option "Expand attribute defaults".

Regards,
Adrian

Re: XHTML transform gets unwnated attribute injected

Posted: Mon Mar 23, 2015 5:09 pm
by amix
Hello Adrian,

thank you very much. Indeed, it was the "-expand" option in the processor settings. And you were right, the document has been linked to xhtml1-strict.dtd. Problem solved :)