that's exactly what they do in Xerces as well :)

http://cvs.apache.org/viewcvs.cgi/xml-xerces/java/src/org/apache/xerces/dom/CoreDocumentImpl.java?annotate=1.62

-- dims

--- Berin Lautenbach <[EMAIL PROTECTED]> wrote:
> Dims,
> 
> One of our dirty little secrets :>.
> 
> Unfortunately the DOM API (regardless of level) has no way of 
> registering that an attribute is of Type ID (except during parse with a 
> DTD or schema).  Level 2 and above have ways of finding (getElementById) 
> and checking (isId), but no way of setting, other than at parse time.
> 
> Given we build the document as we go and then sign, and we prefer to 
> find referenced nodes by Id, we have to register them as we build.
> 
> If anyone knows of a better way to register Ids as we build a document, 
> I'm very open to suggestions!  (If I've missed something in the API - 
> let me know!)
> 
> The only other thing I can think of would be to actually build our own 
> register of Ids as we go.  I.e. when IdResolver.getElementById is 
> called, we run throught he following steps :
> 
> 1. Check the internal Id register.  If element is found, return.
> 2. Call Document.getElementById.  If this works, register the Id in the 
> xml-security register of Ids, then return.
> 3. Work down the current process of finding attributes of the right name 
> (but which are not of type ID).  If found, register in the xml-security 
> register and continue.
> 
> That way, we could register the Id ourselves when we build the document.
> 
> Cheers,
>       Berin
> 
> Davanum Srinivas wrote:
> 
> > Just found another hard-coded dependency on Xerces in IdResolver.java. Is there 
> > anyway to get
> rid
> > of it?
> > 
> >    public static void registerElementById(Element element, String idValue) {
> >       Document doc = element.getOwnerDocument();
> >       ((org.apache.xerces.dom.DocumentImpl) doc).putIdentifier(idValue,
> >               element);
> >    }
> > 
> > Thanks,
> > dims
> > 
> > =====
> > Davanum Srinivas - http://webservices.apache.org/~dims/
> > 
> > 
> 


=====
Davanum Srinivas - http://webservices.apache.org/~dims/

Reply via email to