From: Mathias Hasselmann (Mathias.Hasselmann@gmx.de)
Date: Wed Dec 22 1999 - 08:53:49 EST
Daniel Veillard wrote:
>
> > That's a problem for XSLT parsers: XML document with embedded
> > stylesheets have
> > to start with:
> >
> > <?xml-stylesheet type="text/xml" href="#style1"?>
>
> Hum strange, I wasn't actually able to reproduce the problem:
> ~/XML -> cat pi3.xml
> <?xml version="1.0"?>
> <?xml-stylesheet type="text/xml" href="#style1"?>
> <doc/>
> ~/XML -> ./tester pi3.xml
> <?xml version="1.0"?>
> <?xml-stylesheet type="text/xml" href="#style1"?>
> <doc/>
>
> But I commited a fix checking for a list of predefined PI starting
> with "xml", and verified it only genmerates a warning and don't break
> further processing:
>
> ~/XML -> cat pi4.xml
> <?xml version="1.0"?>
> <?xml-unknown type="text/xml" href="#style1"?>
> <doc/>
> ~/XML -> ./tester pi4.xml
> pi4.xml:2: warning: xmlParsePItarget: invalid name prefix 'xml'
> <?xml-unknown type="text/xml" href="#style1"?>
> ^
> <?xml version="1.0"?>
> <?xml-unknown type="text/xml" href="#style1"?>
> <doc/>
> ~/XML ->
>
> It's commited in the CVS bases
The problem occurs if you take the example for embedded stylesheets
from REC-xslt-19991116 (chapter 2.7):
»»» cut »»»
<?xml-stylesheet type="text/xml" href="#style1"?>
<!DOCTYPE doc SYSTEM "doc.dtd">
<doc>
<head>
<xsl:stylesheet id="style1"
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:import href="doc.xsl"/>
<xsl:template match="id('foo')">
<fo:block font-weight="bold"><xsl:apply-templates/></fo:block>
</xsl:template>
<xsl:template match="xsl:stylesheet">
<!-- ignore -->
</xsl:template>
</xsl:stylesheet>
</head>
<body>
<para id="foo">
...
</para>
</body>
</doc>
««« cut «««
This not nice, but well formed.
James Clark says (in REC-xslt-19991116) something like "This is XML".
So let's ask REC-xml-19980210 about it:
»»» cut »»»
2.8 Prolog and Document Type Declaration
XML documents may, and should, begin with an XML declaration which
specifies the version of XML being used. For example, the following
is a complete XML document, well-formed but not valid:
<?xml version="1.0"?>
<greeting>Hello, world!</greeting>
and so is this:
<greeting>Hello, world!</greeting>
...
Prolog
[22] prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?
[23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>
...
««« cut «««
You see this 'ugly' question mark behind »XMLDecl«?
So this means:
* If you read <?xml version="1.0"?> in the prolog that's
fine, because you known to parse a document meant to be
compilant to version 1.0 of XML.
* If you read <?xml version="somewhat else"?> you have
to enable the "somewhat else" parsing mode and if you
do not know it, you can:
refuse the document
or
inform the user, that you assume that this document
is compatible to XML version 1.0...
* If you never read the xml processing instruction you
are in a similar situation as above. But this time
you have to use the assumtion, that the document
could be compilant to version 1.0...
Ciao,
Mathias
-- WWW: http://www.arco.de/~mhasselm/ http://www.dominanz-haus.de/ PGP-Fingerprint: 4D15 89ED 7299 6428 FEE6 C66F 5D40 6504 55E5 72F3 ---- Message from the list xml@xmlsoft.org Archived at : http://xmlsoft.org/messages/ to unsubscribe: echo "unsubscribe xml" | mail majordomo@xmlsoft.org
This archive was generated by hypermail 2b29 : Wed Aug 02 2000 - 12:29:56 EDT