[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] enclose output of transform in CDATA section


Subject: Re: [xsl] enclose output of transform in CDATA section
From: "W. Eliot Kimber" <eliot@xxxxxxxxxx>
Date: Thu, 14 Aug 2003 09:03:49 -0500

Dave Beattie wrote:

Thanks for your responses. I agree it is inappropriate to place an xml
document in a CDATA section and will attempt to get the requirements
changed. However as I am producing output for a client's existing system I
will probably have to use one of the "dirty" solutions provided.

I completely disagree with Mike Kay on this issue: there is nothing in the XML specification that in any way suggests that it is "inappropriate" to include a syntactic XML document in a CDATA section and I can think of several cases when it would be useful to do so.


How is an XML document embedded in a CDATA section any different then, for example, an EPS graphic embedded inline in an fo:instream-graphic? In both cases you have one complete syntactic unit embedded inside another--the semantics of those syntactic units is irrelevant. And the processing of the embedded data is entirely an application-level issue that is not affected in any way by the syntax issues involved.

The XML specification provides no other way to truly embed one document inside another such that all the document-scoped name spaces (in the generic sense) maintain that scope in the embedded document. That is, while the XML Namespace spec allows you to embed one *element tree* inside another and keep the element type and attribute names distinct, it does not provide a way to keep the notation, entity, and ID name spaces unique and appropriately scoped--these can only be scoped by syntactic isolation. [And let me note that such embedding mechanisms have been discussed at length over the last 10 years, always coming to the conclusion that any markup-level solution would be so complicated as to be untenable, especially when you try to satisfy requirements for some sort of "schema import" mechanism.]

In addition, what if your outer XML document is some sort of payload wrapper (e.g., something like a SOAP message)? If the payload to be wrapped is another, syntactically distinct, XML document then putting that contained document inside a CDATA section is entirely appropriate.

Or said another way, there's no useful difference between embedding a syntactic XML document in which you escape all the markup and one in which you do not by dint of using a CDATA section--the semantic result is the same.

Note that the identity of an XML document *as a storage object* is entirely well defined when it is inside a CDATA marked section--simply address it by XPath relative to its containing document.

If you want to be 100% clear about what the purpose of your CDATA section is you should use a containing element whose content notation is "XML", e.g.:

<?xml version="1.0"?>
<!DOCTYPE mywrapper [
  <!NOTATION xml PUBLIC "http://www.w3.org/TR/xml" >
  <!ATTLIST mywrapper
      datatype
        NOTATION
        #FIXED "xml"
  >
]>
<mywrapper>
<![CDATA[
<?xml version="1.0"?>
<mydoc/>
]]>
</mywrapper>

Given this set of declarations, the syntax and the semantics of the embedded XML document are clear (although the XML declaration is sufficient to make the notation of the CDATA content clear in this case).

Cheers,

E.
--
W. Eliot Kimber, eliot@xxxxxxxxxx
Consultant, ISOGEN International

1016 La Posada Dr., Suite 240
Austin, TX  78752 Phone: 512.656.4139


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




Current Thread
Keywords