Fwd: Re: [xsd-users] Lines numbers after parsing

Jon D tyrecius13 at yahoo.com
Sat Jul 7 21:07:04 EDT 2007


I accidentally didn't reply to the list. Below is my email:

--- Jon D <tyrecius13 at yahoo.com> wrote:

> Date: Sat, 7 Jul 2007 18:05:14 -0700 (PDT)
> From: Jon D <tyrecius13 at yahoo.com>
> Subject: Re: [xsd-users] Lines numbers after parsing
> To: Boris Kolpackov <boris at codesynthesis.com>
> 
> 
> --- Boris Kolpackov <boris at codesynthesis.com> wrote:
> 
> > The most natural way to access this information if by using the
> > DOM association. This feature allows you to keep the DOM tree of
> > your XML document around. You can call the _node () function on
> > a C++/Tree node and get the corresponding DOM node. From there
> > you can get the actual element/attribute name (those are not kept
> > in the C++/Tree nodes) as well as possibly reconstruct the XML
> > fragment to show to the user.
> 
> I was able to do this easily by following the example on your faq.
> 
> > Line and column numbers pose a bit of a problem since Xerces-C++
> DOM
> > tree does not store them (for practical reasons). This, however,
> > is relatively easy to overcome by customizing the XercesDOMParser
> > and storing the line/column information as user data. One example
> > of this approach is available in the Xerces-C++ mailing list
> > archives:
> > 
> > http://marc.info/?l=xerces-c-users&m=115531248220918&w=2
> 
> This turned out to be pretty easy too. I simplified it and thought
> that
> I was ready for prime time. That is when things got very difficult.
> :)
> 
> There were two possible ways of doing the association between nodes
> and
> line numbers. The first is to use the setUserData/getUserData
> facility
> and the second mentioned in that email in an offhand way was to
> create
> a mapping from node addresses to line numbers.
> 
> This works great in a pure-Xerces environment. But when transforming
> it
> into xsd using the name(DOMDocument), everything falls apart. The
> transformation calls cloneNode() which interacts badly with both the
> above options.
> 
> It completely removes the ability to map node addresses. But it seems
> that cloneNode() causes odd problems with the user data as well.
> Sometimes (when it is called on the whole DOMDocument), cloneNode()
> will silently not clone user data or call the DOMUserDataHandler.
> Sometimes (when it is called on a DOMElement), it will do both. The
> name(DOMDocument) call runs it on the DOMDocument which means that
> user
> data is lost.
> 
> I've investigated this to the limits of my ability, looking at the
> source code and trying to find a workaround. But to no avail. I've
> even
> tried updating to the latest SVN version of Xerces-c, but that
> doesn't
> play well with xsd in the least.
> 
> If you have the desire and capability to pursue this further, I can
> provide some minimal demonstration code. I think that the most likely
> problem is that at one point (circa 2001), cloneNode() just ignored
> user data completely
> (https://issues.apache.org/jira/browse/XERCESC-48). Perhaps when they
> added userDataHandlers into the library, notifications were
> inconsistently added.
> 
> Ideally, the solution would be either a patch on Xerces-c fixing the
> bug or a patch on xsd allowing a tree to be created without cloning
> the
> DOM nodes.
> 
> > hth,
> 
> Thanks for your help so far. It seems incredible to me that I have to
> go through such herculean effort just to get error-reporting working.
> 
> 
> 
> 
>        
>
____________________________________________________________________________________
> Get the free Yahoo! toolbar and rest assured with the added security
> of spyware protection.
> http://new.toolbar.yahoo.com/toolbar/features/norton/index.php
> 



       
____________________________________________________________________________________
Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
http://smallbusiness.yahoo.com/webhosting 




More information about the xsd-users mailing list