Couldn't you use "org.xml.sax.helpers.AttributesImpl" and do something like
this

AttributesImpl atts;
atts.addAttribute("", "foo", "foo", "ID", "val");

Myriam


                                                                                       
                    Paul Winder                                                        
                    <pwinder@arbor       To:     [EMAIL PROTECTED],             
                    text.com>             [EMAIL PROTECTED]                     
                                         cc:     [EMAIL PROTECTED],             
                    06/20/01 03:32        [EMAIL PROTECTED], [EMAIL PROTECTED], 
                    PM                    [EMAIL PROTECTED], (bcc: Myriam       
                    Please respond        Midy/CAM/Lotus)                              
                    to xalan-dev         Subject:     Re: Using the id() function with 
                                          SAX input                                    
                                                                                       




I would be happy to do something like that (although it would be much nicer

to do something global
up front).

However, I'm using the Java version, and I find nothing in the API
corresponding to attrs.addAttribute().  I see lots of methods for _getting_

type information, but none for setting it.

Paul

At 03:01 PM 6/20/01 -0400, [EMAIL PROTECTED] wrote:

>I'm not sure I understand the problem.  If you're pushing SAX events to a
>ContentHandler, then you must be constructing the attributes, so can't you
>just create an attribute with the proper type?  Then, any ContentHandler
>implementation that understands ID attributes will detect that the
>attribute is an ID and do the right thing.
>
>I don't know what implementation of the SAX Attributes class you are
using,
>but in Xalan-C++, this would look something like this, assuming that my
>string literals are proper Unicode:
>
>void
>foo(ContentHandler*   handler)
>{
>      XalanAttributesImpl   attrs;
>
>      attrs.addAttribute("foo", "ID", "val");
>
>      handler->startElement("", "foo", "foo", attrs);
>      handler->endElement("", "foo", "foo");
>}
>
>Or am I misunderstanding what you're trying to do?
>
>Dave
>
>
>
>
>
>                     Paul
> Winder
>
>                     <pwinder@arbo        To:     [EMAIL PROTECTED]

 >
>                     rtext.com>           cc:
> [EMAIL PROTECTED], [EMAIL PROTECTED],
>                                          [EMAIL PROTECTED], (bcc:
> David N Bertoni/CAM/Lotus)
>                     06/20/2001           Subject:     Re: Using the id()
> function with SAX input
>                     01:35
> PM
>
>                     Please
 >
>                     respond
> to
>
>                     xalan-dev
 >
>
>
>
>
>
>
>
>Hi Scott,
>
>Sorry to pester you with this, but we have code freeze in a day or so and
>this is a must fix.
>
>Ideally I'd like to have a global solution, such as the attributeDecl()
>method I mentioned below.
>Failing that, there is an alternative that John Dreystadt and I discussed
>that combines David Bertoni's response and yours.
>
>Basically, after the startElement() method of the TransformerHandler is
>called, we would specify the ID attribute of the element just created:
>
>    myTransformerHandler.startElement(theElement, itsAttributes);
>    currentElement = (Element)<<?>>.getCurrentNode();
>    <<?>>.SetIDAttribute(idString, currentElement);
>
>This seems clearcut.  My problem is <<?>>:  this is an StreeDomBuilder,
but
>
>how do I derive this from the TransformerHandler?
>Also, will I have to change this when Stree goes away?
>
>As to the attributeDecl() concept, for that I need a SourceTreeHandler;
how
>
>do I derive that from the TransformerHandler?
>It sure would be nice if the TransformerHandler, along with its many other
>hats, wore that of a Declhandler...
>
>Paul
>
>At 11:15 AM 6/20/01 -0400, Paul Winder wrote:
> >At 05:34 PM 6/19/01 -0400, [EMAIL PROTECTED] wrote:
> >
> >>Xalan just looks at the incoming attributes and watches for those of
type
> >>ID.  A validating parser should set the right type if it has access to
>the
> >>DTD.  If you are manufacturing input, just set the right type when you
> >>create the attribute.  Xalan does very little -- nothing for you
>purposes,
> >>with the DTDHandler.
> >
> >How about the attributeDecl() method in the DeclHandler interface, which
> >is implemented by
> >SourceTreeHandler--would that do what I need?
> >
> >If so, what would I specify for the first argument, ename?  Would I have
> >to call the function for each
> >element for which I wanted the attribute recognized as an ID attribute,
or
>
> >is there a wildcard value?
> >
> >Paul
> >
> >>-scott
> >>
> >>
> >>
> >>
> >>
> >>                     Paul Winder
> >>                     <pwinder@arbo        To:
>[EMAIL PROTECTED]
> > >
> >>                     rtext.com>           cc:     (bcc: Scott
>Boag/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