Re: [xsl] overriding <xsl:output> attributes

Subject: Re: [xsl] overriding <xsl:output> attributes
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 08 Jul 2010 20:51:44 -0400
At 2010-07-08 16:34 -0700, Lynn Murdock wrote:
i have a document A that imports document B.

in the <xsl:output> instruction, document B specifies doctype-public and doctype-system attributes. in document A, i want to disable output of doctypes, as we add the doctype declaration at another point in our production pipeline (ie, not in the xsl).
...
simply omitting the doctype statements in the importing document does not disable the output of doctype statements. according to michael kay's book, a specified attribute within <xsl:output> takes precedence over an omitted attribute, regardless of which document it's in (importing or imported).

Yes, the *attributes* are overridden, not the entire instruction.


i have tried adding a name attribute to the importing statement, to try to create a new output definition, with no success. i have also tried using doctype-public="" and doctype-system="" in the importing document, but these simply output a doctype statement with a "" value.

is there a way to completely disable the output of these statements in the resulting html, given that i can't modify the imported document?

No. I can't think of any way.


But I can give you an "ineffectual" declaration so that you produce a DOCTYPE but it doesn't add anything to your document:

This works in DOS:

<!DOCTYPE abc PUBLIC "" "nul"
[
<!ELEMENT abc EMPTY>
]>
<abc/>

This works in Unix:

<!DOCTYPE abc PUBLIC "" "/dev/null"
[
<!ELEMENT abc EMPTY>
]>
<abc/>

So you just need doctype-public="" and doctype-system="/dev/null" or "nul".

i'm using saxon 8.7, and xsl 2.0.

any insight into this issue would be much appreciated.

This is along the same lines as being able to add attributes to an element in the result tree, but not remove them.


I hope this helps but I realize it doesn't get you your desired result of omitting the declarations ... nevertheless the declarations above will give you the same effect as if not having them. Unfortunately it isn't portable. If you need a portable solution, then create an empty file in your system and point to it using the doctype-system.

. . . . . . . . . . Ken

--
XSLT/XQuery training:   after http://XMLPrague.cz 2011-03-28/04-01
Vote for your XML training:   http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread