You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Michael Glavassevich <mr...@apache.org> on 2004/06/18 19:31:16 UTC

Xerces-J Users Feedback Requested

Hello everyone,

I find when we receive feedback about Xerces-J, it's quite often about a 
bug a user has found (with the odd request for an enhancement).  Xerces-J 
has widespread usage and is incorporated into many applications, including 
several of the other Apache projects, though I don't think we have a good 
handle as to how Xerces is being used at large.  I can think of a number 
features which are rarely (if ever) discussed on these lists which I'm 
sure are being used creatively by someone, somewhere out there.  It would 
be interesting to hear about user's experiences with Xerces, the types 
of projects it's being used in and the things you wish you could be doing 
with the parser.  Your feedback would certainly help us in planning future 
releases.

Thanks.

---------------------------
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Xerces-J Users Feedback Requested

Posted by Andy Clark <an...@cyberneko.net>.
Michael Glavassevich wrote:
> someone, somewhere out there.  It would be interesting to hear about 
> user's experiences with Xerces, the types of projects it's being used in 
> and the things you wish you could be doing with the parser.  Your 
> feedback would certainly help us in planning future releases.

Oops! I essentially said the same thing in replying to Adrian's
post. I guess that's my fault for reading messages chronologically.
Oh well...

-- 
Andy Clark * andyc@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Xerces-J Users Feedback Requested

Posted by Nikhil Dinesh <ni...@seas.upenn.edu>.
Hi,

Here is something Id like to see incorporated though Im not sure if it is
possible or whether this is more appropriate for something like Xalan. But
anyway...here goes:

The application in mind is querying and editing structures like trees and
graphs. The representation that we usually start with has the structure
encoded in it either overtly or subtly. So we transform in memory to some
representation. A lot of people have written querying/searching mechanisms
for DOMs like XPath and so I find I have to keep writing light DOMWrappers
for these kinds of structures so quering can be plugged in. Though this is
easy enough it is a little irritating because of the size of the
interfaces. So I was wondering if a growing API of wrappers to structures
like trees, graphs, sets etc could be attempted. The emphasis being
decreased flexibility, lower memory consumption and higher speed.

Just a thought.

-Nikhil

On Fri, 18 Jun 2004, Michael Glavassevich wrote:

> Hello everyone,
>
> I find when we receive feedback about Xerces-J, it's quite often about a
> bug a user has found (with the odd request for an enhancement).  Xerces-J
> has widespread usage and is incorporated into many applications, including
> several of the other Apache projects, though I don't think we have a good
> handle as to how Xerces is being used at large.  I can think of a number
> features which are rarely (if ever) discussed on these lists which I'm
> sure are being used creatively by someone, somewhere out there.  It would
> be interesting to hear about user's experiences with Xerces, the types
> of projects it's being used in and the things you wish you could be doing
> with the parser.  Your feedback would certainly help us in planning future
> releases.
>
> Thanks.
>
> ---------------------------
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Xerces-J Users Feedback Requested

Posted by Elliotte Rusty Harold <el...@metalab.unc.edu>.
I use Xerces as the primary backend parser for XOM. 
<http://www.cafeconleche.org/XOM/>. I chose it because it seems more 
reliable and conformant to the XML specification than other Java 
parsers. (Yay Xerces!)

My one big annoyance with the product that's forced me to delve into 
its internals is the mandated support for XML 1.1. There's no simple 
feature I can set to require XML 1.0. Like a lot of other 
applications XOM is built around an assumption of XML 1.0 
well-formedness, and is not prepared to accept XML 1.1 documents. 
Turning off 1.1 support seems to require writing your own 
ParserConfiguration class.

That was non-trivial, but what was worse was that setting the 
ParserConfiguration is based on a System property that affects all 
instances of Xerces in the virtual machine, not just mine. In the 
worst case, these can be instances loaded by other class loaders that 
do not have access to my ParserConfiguration class. Thus loading XOM 
can break all other uses of Xerces. :-( This is a particular problem 
in server-side environments like Tomcat.

I eventually hacked around this by subclassing 
org.xml.apache.xerces.parsers.SAXParser so I could use the 
constructor that sets the ParserConfiguration rather than using the 
system property. (For various reasons involving the need to run with 
other parsers and without Xerces installed I couldn't just use the 
constructor directly.) This mostly works, but I still have problems 
with Xerces XMLReaders passed to me by clients as opposed to being 
created directly in my code. I've worked around this too, but the 
workaround has a measurable cost in parse time. In essence, all name 
and text well-formedness checks are performed twice, once in Xerces 
and once  by XOM.

There is one silver lining here. If someone is marking a document XML 
1.1 for no good reason (i.e. they aren't actually using any of the 
features of XML 1.1 beyond the new version number) XOM can now 
correctly parse it and transform it to 1.0 on output. However, that's 
a minor benefit. If Xerces had a simple SAX property to turn off 1.1 
for any given instance of org.apache.xerces.parsers.SAXParser (and 
only that instance), then I could stop hacking around in the Xerces 
internal API and be quite happy.
-- 

   Elliotte Rusty Harold
   elharo@metalab.unc.edu
   Effective XML (Addison-Wesley, 2003)
   http://www.cafeconleche.org/books/effectivexml
   http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Xerces-J Users Feedback Requested

Posted by "Mgr. Martin Vysny" <vy...@host.sk>.
Andy Clark wrote:

>
>> not yet resolved AFAIK (I'm using version 2.6.2). If the entity
>> "foo" is declared but not used in the XML then the code 
>> doc.getDocument().getDoctype().getEntities().getNamedItem("foo") 
>> returns the instance of Entity interface that does not have a single
>>  child - no Text nodes, nothing. I am currently implementing the
>
>
> Unfortunately (for you) this is a feature. And it was implemented
> this way mainly for performance reasons. If an entity is never
> referenced in the document, then we never have to waste time
> reading it. If the external entity is huge but never referenced,
> we don't waste time or memory.
>
I understand these reasons and they are of course reasonable when Xerces 
user does not plan to modify the document by inserting entities. However 
it is quite common to modify DOM document and in such case these 
entities should have correct content. I think that there should be a 
property/feature that should set full entity loading on or off (and the 
default value should be "off"). I can of course implement this behaviour 
using XNI. My question is: can I manually set the contents of Entity 
node (by overriding the readOnly flag) and expect that this content will 
appear in each created EntityReference node (if yes then is it an 
expectable or Xerces-specific behaviour)? Next question: can I modify 
contents of Entity node and expect that this change will be reflected to 
all EntityReference instances?

>
> Take the following document and external entity:
>
>   <!-- entity.ent -->
>   <hello/>
>
>   <!-- document.xml -->
>   <!DOCTYPE root [
>   <!ENTITY entity SYSTEM 'entity.ent'>
>   ]>
>   <root>
>     <sub xmlns='foo'> &entity; </sub>
>     <sub xmlns='bar'> &entity; </sub>
>   </root>
>
> Notice that the default namespace is different at each point
> where the entity is referenced. This means that the <hello/>
> element will be bound to different namespaces. So both
> instances of the same entity are actually different elements!
>
> In this situation, what should the Entity node in the DOM doctype
> return: children in the "foo" namespace or children in the "bar"
> namespace?
>
> In short, it's a complicated issue.
>
I agree that there are many complications with this issue. If we do not 
want to break the xmlns inheritance rule then <hello/> element shall 
have different namespace in these two cases and I personally cannot find 
any rule saying which namespace should be preferred in the Entity node. 
I think that the hello element should have null namespace in the Entity 
node (because it would have this namespace if it would be loaded as an 
XML file) and appropriate namespaces in both EntityReference nodes.

However this brings more complications: a) EntityReference and Entity 
will have different content and this may result in high memory 
consumption b) when moving this EntityReference then the namespaces of 
hello element must be updated c) if Entity is changed then this change 
should be reflected to all EntityReferences. Maybe the other approach 
would be better (it is currently implemented this way afaik): we can 
simply insert xmlns="" attribute into the <hello/> element (or each root 
element, imho entity may have more than one root element). This seems 
quite logical: a) if we read entity.ent as an independent XML file then 
<hello/> shall have null namespace, b) two namespaces are usually very 
different, they have usually their own schema so there is imho no point 
in having same element tree with two different namespaces.

When I thought about the b) case the third option came to my mind: find 
first occurence of EntityReference, inherit the namespace and update the 
Entity node. If the EntityReference is used in another namespace then an 
error may be raised. However there is a problem if the entity is not 
used, and the bigger problem: if we do not want to have a valid document 
then we should be able to put entities freely everywhere we want. So I 
think that the first suggestion may be a way to solve the issue.

Thank you very much for your answers.
Sincerely,
Martin Vysny

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Xerces-J Users Feedback Requested

Posted by Andy Clark <an...@cyberneko.net>.
Mgr. Martin Vysny wrote:
> My second question relates to one parser bug. There is a bug that is
>  not yet resolved AFAIK (I'm using version 2.6.2). If the entity
> "foo" is declared but not used in the XML then the code 
> doc.getDocument().getDoctype().getEntities().getNamedItem("foo") 
> returns the instance of Entity interface that does not have a single
>  child - no Text nodes, nothing. I am currently implementing the
> entity modification so I am quite interested in this issue. Question:
> is it a bug or a feature? I hope it's a bug ;)

Unfortunately (for you) this is a feature. And it was implemented
this way mainly for performance reasons. If an entity is never
referenced in the document, then we never have to waste time
reading it. If the external entity is huge but never referenced,
we don't waste time or memory.

Plus, there is a deeper problem in relation to namespaces. DOM
can't even help. I'll explain...

Take the following document and external entity:

   <!-- entity.ent -->
   <hello/>

   <!-- document.xml -->
   <!DOCTYPE root [
   <!ENTITY entity SYSTEM 'entity.ent'>
   ]>
   <root>
     <sub xmlns='foo'> &entity; </sub>
     <sub xmlns='bar'> &entity; </sub>
   </root>

Notice that the default namespace is different at each point
where the entity is referenced. This means that the <hello/>
element will be bound to different namespaces. So both
instances of the same entity are actually different elements!

In this situation, what should the Entity node in the DOM doctype
return: children in the "foo" namespace or children in the "bar"
namespace?

In short, it's a complicated issue.

You might be best off trying to read the document fragment
yourself when you look for the Entity node and it has no
children. Xerces has a document fragment scanner in the impl
package that would be useful for this purpose. You'd have to
write code that builds children for a DOM document fragment
from XNI methods, though. But this isn't hard to do. I can
point you to an example if you need it.

> The main topic I would like to discuss is the support of the 
> validation. I found the validation system present in Xerces lacking
> some key features. I had to develop my own validation routines based
> on MSV. Why? 1. AFAIK Xerces supports only DTD and XML Schema, but
> not Relax, Relax NG etc. 2. The validation of multiple-namespaced

I have a project called "CyberNeko tools for XNI" that has a
RelaxNG parser configuration for Xerces. You instantiate Xerces
based parsers and it passes the information to Jing on the
inside. So that's another option. Here's a link:

   http://www.apache.org/~andyc/neko/doc/relaxng/

-- 
Andy Clark * andyc@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Xerces-J Users Feedback Requested

Posted by "Mgr. Martin Vysny" <vy...@host.sk>.
Hi everyone,
  I'm pleased to see this type of thread, I'd love to hear the way which 
Xerces shall (should) take. So, allow me to say some words how do I use 
Xerces, and to find answers for some questions still unanswered. Please 
forgive my bad english :).
  We are working on an open-source WYSIWYG XML Editor (it can be found 
at [1]). We are using Xerces as an in-memory holder of the edited 
document, parser and serializer. Most of all I am pleased with the 
current implementation of DOM3. My first question is: what is the 
progress of the implementation of DOM3 load/save functions, I'd like to 
use them if possible.
  My second question relates to one parser bug. There is a bug that is 
not yet resolved AFAIK (I'm using version 2.6.2). If the entity "foo" is 
declared but not used in the XML then the code 
doc.getDocument().getDoctype().getEntities().getNamedItem("foo")
returns the instance of Entity interface that does not have a single 
child - no Text nodes, nothing. I am currently implementing the entity 
modification so I am quite interested in this issue. Question: is it a 
bug or a feature? I hope it's a bug ;)
  The main topic I would like to discuss is the support of the 
validation. I found the validation system present in Xerces lacking some 
key features. I had to develop my own validation routines based on MSV. 
Why? 1. AFAIK Xerces supports only DTD and XML Schema, but not Relax, 
Relax NG etc. 2. The validation of multiple-namespaced documents, when 
the schemata are mutually independent (they are not linked to each 
other) is still not described well AFAIK. An example: let's have a FO 
file. We want to put a MathML formula into this XSL-FO file (into the 
fo:external-blah-blah element). To achieve correct validation in Xerces 
we must: a) link FO schema with the MathML schema, thus we must create a 
new instance of the FO schema with a link to the MathML schema, OR b) we 
may specify that fo:external-whatever element may contain any content, 
however we shall not achieve full validation. I implemented a solution 
(described briefly at [1] section 4.4.2), however it is not a standard 
solution. I appreciate any comments on this issue.
  It may look that I don't think very positively of Xerces :). Nope, 
Xerces is very good piece of software and I am looking forward to use it 
in my next projects.
Sincerely,
Martin Vysny

[1]  http://www.dcs.fmph.uniba.sk/euromath2


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org