On Sun, Mar 30, 2008 at 6:17 PM,  <[EMAIL PROTECTED]> wrote:
>
> If you need to know entity-reference boundaries, you can get that
> information by asking the parser to generate a DOM which has Entity
> Reference Nodes and then looking at the children of the attribute nodes.
> (I'm not sure offhand whether there's a SAX equivalent.)

I using SAX rather than DOM because my library is compiling a xml
template (not XSL but another template format), so for me building the
AST using SAX is much easier and reduces both the time and the space
usage. Using DOM in this case would just create a large intermediate
representation that would be discarded anyway and would force me to
walk the tree instead of doing a state machine (which I prefer for
compilers).

> If you want to suppress the other kinds of normalization applied to
> attributes, I would suggest that you don't want attributes in the first
> place. Change your document design so this information is carried by a child
> element. (See much past discussion -- just about everywhere that XML is
> discussed! -- about when to use attributes vs. child elements; this is one
> classic example where there is a practical reason rather than just one of
> style.)

What I'm doing can't really restrict the things that the source XML
contains, because any XML is a valid template for my library. For
example if I have <foo bar="foo &amp; bar"/> I need to be able to
parse this and compile a template that when run will result in <foo
bar="foo &amp; bar"/>, essentially the identity function. Actually
this is one of the problems that (now) I don't think if it's possible
to solve with SAX: create a handler that will build a exact copy of
the parsed XML.

>  ______________________________________
>  "... Three things see no end: A loop with exit code done wrong,
>  A semaphore untested, And the change that comes along. ..."
>   -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish
> (http://www.ovff.org/pegasus/songs/threes-rev-11.html)

Best regards,
Daniel Yokomizo.

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

Reply via email to