Re: [xslt] DTD validation and default attributes
- From: Michael Ludwig <mlu as-guides com>
- To: The Gnome XSLT library mailing-list <xslt gnome org>
- Subject: Re: [xslt] DTD validation and default attributes
- Date: Thu, 02 Apr 2009 18:30:24 +0200
Daniel Veillard schrieb:
On Thu, Mar 26, 2009 at 11:28:08AM +0100, Michael Ludwig wrote:
(4) While default attributes are supplemented running a
transform, validation does not seem to occur, as no error
is flagged. Is this the intended behaviour? Note there is
yes
a --novalid option, which seems to imply validation is
intended to occur by default
xsltproc run without arguments will print
--novalid skip the Dtd loading phase
i.e. this argument means the external subset is not loaded.
Good, the external subset is not loaded. That clarifies it. It might
be argued that the option is misnamed, especially as xmllint (but
not xsltproc) has an option named --loaddtd.
(5) Using the --novalid option, default attributes as per the
internal subset are not translated into the XPath Data Model
which the transformer gets to work on. Is this intended? Note
there is also a --nodtdattr option to xsltproc. It does what
it says, but this doesn't seem to be different from --novalid.
You would see the difference if your document had an external
subset. You could still fetch the external subset, say to load
entities but not expand to add the associated defaulted attributes.
Excellent, thanks!
Here's a short test case to illustrate the behaviour for the curious:
$ cat xsltproc-novalid-dtdattr.xml
<!DOCTYPE Urmel SYSTEM "xsltproc-novalid-dtdattr.dtd" [
<!ENTITY intern "INTERN">
<!ATTLIST Urmel intern CDATA #FIXED "ha">
]>
<Urmel> &intern; &extern; </Urmel>
$ cat xsltproc-novalid-dtdattr.dtd
<!ENTITY extern "EXTERN">
<!ATTLIST Urmel extern CDATA #FIXED "hi">
$ xsltproc identity.xsl xsltproc-novalid-dtdattr.xml
<?xml version="1.0"?>
<Urmel intern="ha" extern="hi"> INTERN EXTERN </Urmel>
$ xsltproc --nodtdattr identity.xsl xsltproc-novalid-dtdattr.xml
<?xml version="1.0"?>
<Urmel> INTERN EXTERN </Urmel>
$ xsltproc --novalid identity.xsl xsltproc-novalid-dtdattr.xml
xsltproc-novalid-dtdattr.xml:5: parser error : Entity 'extern' not defined
<Urmel> &intern; &extern; </Urmel>
^
<?xml version="1.0"?>
<Urmel> INTERN </Urmel>
A warning is flagged, because the entity declaration in the external
subset has not been made available.
And while we're at it, how does xmllint behave when fed this document?
$ xmllint xsltproc-novalid-dtdattr.xml
xsltproc-novalid-dtdattr.xml:5: parser error : Entity 'extern' not defined
<Urmel> &intern; &extern; </Urmel>
^
<?xml version="1.0"?>
<!DOCTYPE Urmel SYSTEM "xsltproc-novalid-dtdattr.dtd" [
<!ENTITY intern "INTERN">
<!ATTLIST Urmel intern CDATA #FIXED "ha">
]>
<Urmel> &intern; &extern; </Urmel>
$ xmllint --loaddtd xsltproc-novalid-dtdattr.xml
<?xml version="1.0"?>
<!DOCTYPE Urmel SYSTEM "xsltproc-novalid-dtdattr.dtd" [
<!ENTITY intern "INTERN">
<!ATTLIST Urmel intern CDATA #FIXED "ha">
]>
<Urmel> &intern; &extern; </Urmel>
$ xmllint --noent xsltproc-novalid-dtdattr.xml
xsltproc-novalid-dtdattr.xml:5: parser error : Entity 'extern' not defined
<Urmel> &intern; &extern; </Urmel>
^
<?xml version="1.0"?>
<!DOCTYPE Urmel SYSTEM "xsltproc-novalid-dtdattr.dtd" [
<!ENTITY intern "INTERN">
<!ATTLIST Urmel intern CDATA #FIXED "ha">
]>
<Urmel> INTERN &extern; </Urmel>
$ xmllint --loaddtd --noent xsltproc-novalid-dtdattr.xml
<?xml version="1.0"?>
<!DOCTYPE Urmel SYSTEM "xsltproc-novalid-dtdattr.dtd" [
<!ENTITY intern "INTERN">
<!ATTLIST Urmel intern CDATA #FIXED "ha">
]>
<Urmel> INTERN EXTERN </Urmel>
$ xmllint --dtdattr xsltproc-novalid-dtdattr.xml
<?xml version="1.0"?>
<!DOCTYPE Urmel SYSTEM "xsltproc-novalid-dtdattr.dtd" [
<!ENTITY intern "INTERN">
<!ATTLIST Urmel intern CDATA #FIXED "ha">
]>
<Urmel intern="ha" extern="hi"> &intern; &extern; </Urmel>
So --dtdattr implies --loaddtd, while --noent doesn't.
Michael Ludwig
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]