Re: DOCTYPE handling in XML

Michael Ludwig <[email protected]>
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
Peter T Cash schrieb:
> Liam Quin <[email protected]> wrote on 10/22/2008 07:38:51 AM:
>> On Tue, Oct 21, 2008 at 10:44:11AM -0500, Peter T Cash wrote:
>>> For what it's worth, this appears to be a general limitation of XML
>>> tools. I've been writing XSLs and running them with the Saxon
>>> parser; I ran into the same problem. There's apparently no way to
>>> get an XSL transform to process an XML document and preserve ENTITY
>>> declarations. This appears to be a side effect of the fact that the
>>> parser won't copy the DOCTYPE declaration to the output, and the
>>> ENTITY declarations are part of the DOCTYPE.
>>
>> It's nothing of the sort.
>
> The referent of "it" is unclear in this context. Care to be less
> delphic?

"It" refers to the same thing as "This" in your sentence starting with
"This appears to be a side effect [...]".

>> It's because most XML tools work on the result of parsing XML, and
>> entities are expanded during parsing.
>
> A parser is not, then, a tool?

Not if you oppose tools to parsers, as Liam did, and with a reason, as
you referred to the Saxon XSLT processor as a "parser", which it is not.

http://saxon.sourceforge.net/aelfred.html

First, the XML document is parsed by a parser, and then the result of
parsing is fed to the XSLT processor. The process of parsing expands
all entities, so the XSLT processor never gets to see the entity
declarations or entity references.

I think that when designing XSLT they wanted to shield it from DTD
stuff. Is that correct, Liam?

> --In any case, the issue does not concern expanding entity references,
> but about preserving their declarations in the output (say, in the
> result of an identity template used to make changes to an existing XML
> document). If you know how to do this via an XSL transform (as opposed
> to, say, Perl string and file manipulation), then I (and the original
> questioner) would be grateful for any help you could provide. If you
> don't know how to do it...then why did you bother to reply?

Ts, ts. Just be grateful for a good answer, unconditionally. It's easy.

I don't know the answer either. But read this:

RE: [xsl] accessing the input XML's doctype
http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/200807/msg00431.html

I'd ask on the XSL-List, that'll definitely clarify the issue.

See also the LexEv tool by Andrew Welch: http://andrewjwelch.com/lexev/

     - process CDATA sections as markup
     - preserve entity references in the output
     - preserve character references in the output
     - preserve the DOCTYPE in the output

And XML::Twig.

>> You can use XInclude as an alternative mechanism in many cases.
>
> And this is relevant to the problem exactly how?

Yes, how could XInclude be used to preserve entity declarations? Or
would you include a XInclude reference to another document containing
those entity declarations? The entity references would still be gone
after the XSL stage, though, would they not?

Michael Ludwig
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.