Why don't you do it the "SAX" way and make sure the type of the attribute
that you want to be an id is "ID"?

Here's a code snippet from Xalan-J's STreeDOMBuilder:

        if (atts.getType(i).equalsIgnoreCase("ID"))
          setIDAttribute(atts.getValue(i), elem);

I know that the STree is deprecated, but the new source tree should work
the same way, since it's standard SAX behavior.

Since there's no validation, you'll need to ensure that the IDs are valid
names and are unique.

Dave



                                                                                       
                           
                    Paul Winder                                                        
                           
                    <pwinder@arbo        To:     [EMAIL PROTECTED]              
                           
                    rtext.com>           cc:     (bcc: David N Bertoni/CAM/Lotus)      
                           
                                         Subject:     Using the id() function with SAX 
input                      
                    06/19/2001                                                         
                           
                    04:10 PM                                                           
                           
                    Please                                                             
                           
                    respond to                                                         
                           
                    xalan-dev                                                          
                           
                                                                                       
                           
                                                                                       
                           



Hi all,

We are using Xalan 2.1.0 with SAX input from our SGML/XML editor.  So far,
it's working great, but I found a possible limitation today that worries
me.

In our editor we can apply links and link targets to an XML Docbook
document, as <link> tags with href attributes and anchor tags with id
attributes, respectively.  We are processing the document using Norm
Walsh's XSLDocbook10 (version 1.4) stylesheet.  Norm uses the id() function

to locate the target node for a link.

The problem is that the id() function relies on an ID attribute designated
in the DTD.  Since we are using SAX input, Xalan does not have the DTD, and

therefore does not have a designated ID attribute, so the id() function
always comes up with no matches.

Is there any other way to designate the ID attribute to Xalan aside from
the DTD?

Failing that, is there a way to give Xalan the DTD for the document when
the input is through SAX?  I looked at the LexicalHandler interface, and
there is mention of sending the "external DTD subset" in a startEntity()
event using the special name "[dtd]", but it isn't clear to me if this
would do what I need or how to do it.

Any help would be appreciated.

Paul Winder
Arbortext






Reply via email to