Matt Benson wrote:
[...] AFAIK a
non-well-formed fragment should forego the
declaration.

I believe you can actually put an XML declaration in a doc with multiple top-level fragments, if you are using it as a parsed external entity. (Only useful to declare the encoding.) But I guess that few people would ever do this.

If so, we can do one of the following:

1) Disallow > 1 direct child of <echoxml>
2) Always write fragments, skipping the declaration.
3) Automatically include the declaration when there
   is only one direct child element.

Eek.

4) Add some sort of cumbersome configuration options.

XML not being my forte, I can say that 2) is simplest.

(1) or (2) is simplest, but for (4) it might be convenient to just be able to say

<echoxml includedeclaration="true">
    <root/>
</echoxml>

and omit support for writing a DOCTYPE etc. On the other hand, writing a declaration manually with <echo> and CDATA is not hard.

There may be other subtleties for namespaces - e.g. if writing a single element, you can automatically generate namespace aliases, otherwise you may need aliases on each fragment. And careful about character encoding.

...

Possibly dumb semi-related idea: have the body of the task actually be an inline XSLT script with dummy input and the option to use the minimized form ("Literal Result Element as Stylesheet" in spec). Then you could use e.g.

<echoxml>
    <root xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
          xsl:version="1.0">
        <xsl:if test="${property.from.script.here} = 'true'">
            <optional-subelement/>
        </xsl:if>
    </root>
</echoxml>

In this case there is no need to worry about writing out XML precisely (JAXP handles it), and you can write out well-formed XML decls etc. using the full

<echoxml>
    <xsl:stylesheet ...>
        <xsl:output method="xml" .../>

though I guess you cannot write out parallel fragments this way.

But I think I am inviting a flame war for suggesting it. :-)

-J.

--
[EMAIL PROTECTED]   x22801   netbeans.org   ant.apache.org
if I had known it was harmless I would have killed it myself


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to