RE: [xsl] Select entire XML doc

Subject: RE: [xsl] Select entire XML doc
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 04 Mar 2003 13:45:24 -0500
Hi Brian,

At 12:24 PM 3/4/2003, you wrote:
Normally all I would want when doing
a copy are elements.  I didn't realize that you *can* copy all nodes in a
source document, probably because there's little point in doing so since you
would just create an exact copy of the source.

Probably the commonest example in my experience is the technique of adapting an identity stylesheet to tweak a document only in places.


  Perhaps if you were copying
multiple sources to the result tree and wanted everything, including the
<?xml?> declaration--but then the result wouldn't be well-formed XML,
correct?

Yes -- with one tiny (but potentially important) caveat. The XML declaration <?xml version="1.0"?> is *not* a processing instruction, and is *not* present in the XPath data model. So in a document that starts:


<?xml version="1.0" encoding="funkyencoding"?>
<?xml-stylesheet href="myfunkyxform.xsl" type="text/xsl"?>

the xml-stylesheet PI is available, but the XML declaration (which looks just like a PI) is not -- nor is the information stored in it (such as that this data purportedly started life in some funkyencoding).

Why does the XML declaration look like a PI? (I hear you cry) if it's not?

One answer: for backwards compatibility with older (SGML) parsers that would not complain on a PI, but would gag if handed a declaration they didn't recognize. (The usual XML declaration syntax being, in conformance to SGML practice, <!...> .) Once upon a time this was a very handy workaround; it's still occasionally useful sometimes (at the cost of terrible confusion to parser writers or programmers who want "the XML processing instruction").

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread