You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by Fredrik Vraalsen <fr...@vraalsen.no> on 2005/07/14 10:30:45 UTC

IDREF and xjc:dom

Hi,

First of all, I've been using JaxMe for a while, thanks for all the
great work! :)  However, recently I've gotten some new requirements
which have forced me to move to the JAXB Reference Implementation.

Firstly, my project needs support for the xjc:dom extension to import
arbitrary XML as a DOM tree.  Is there any ongoing work to support this
in JaxMe?

Secondly, I use IDREF to handle references between various objects which
are not structured in a strictly hierarchical fashion.  JaxMe's
implementation of IDREF differs from the JAXB specification and the RI,
as JaxMe only sets/gets the IDREF String itself, as opposed to the RI
which sets/gets the actual object being referenced.  See the spec
(section 5.8.2) for more info.  I've also opened a new JIRA issue
(http://issues.apache.org/jira/browse/JAXME-58).

If you could point me to the appropriate files I could also have a look
at this myself.


Best regards,

Fredrik Vraalsen
SINTEF - http://www.sintef.no/


---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: IDREF and xjc:dom

Posted by Jochen Wiedmann <jo...@gmail.com>.
Fredrik,

sorry for being bureacrazy, but please be so kind to attach the files to 
JAXME-58. This is also the best place for discussing the topic. Note, 
that all JIRA comments and attachments are automatically delegated to 
this mailing list.


Regards,

Jochen


---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: IDREF and xjc:dom

Posted by Fredrik Vraalsen <fr...@vraalsen.no>.
Fredrik Vraalsen wrote:

> I've also attached the schema I'm interested in compiling with JaxMe, in 
> case you are interested.

Doh!  That was not the right version of the schema... :-/  I can send 
you correct schemas later if you are interested.

Fredrik

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: IDREF and xjc:dom

Posted by Fredrik Vraalsen <fr...@vraalsen.no>.
Jochen Wiedmann wrote:
> Hi, Fredrik,
> 
> both things shouldn't be technically too difficult. I'll start with
> the ID/IDREF thing, we may return to the xjc:dom implementation later.
> 
> Forgetting for a moment, that the actual bean classes need changes,
> I'll suggest that we start with validating the IDREF's. We'll later
> see, that this is actually most of the work, if we do it right.
> 
> If an object has embedded ID/IDREF's, then its generated SAX handler
> needs two additional objects:
> 
>   - A Map for storing the ID's and and the elements, to which are
> being mapped. An
>     element is added to this Map, whenever the SAX handler detects an
> ID. The Map
>     keys are the ID's and the Map elements are the associated elements.
>   - A List for storing the IDREF's. Whenever the SAX handler detects
> an IDREF, then
>     it adds an implementation of the interface
> 
>             interface IDREF {
>                 void validate(Map pIds) throws SAXException;
>             }
> 
>     The idea is, that the SAX handler will invoke all the IDREF's
> within endDocument().
>     Obviously, if the IDREF implementation is a suitable inner class,
> then it can not
>     only validate the reference, but invoke a proper setter as well.
> 
> For that first step, you should be able to work within the class
> DriverSGImpl and its subclasses only, so a deeper understanding of all
> the JaxMe details shouldn't be required.

Dear Jochen,

I started looking at this.  I've attached a first small patch to 
retrieve and store IDs from attributes in the SAX handler.  I haven't 
added checking for duplicate IDs yet.  However, to make this work 
properly (both duplicate checking and IDREF lookup), I think this map 
may need to be made global across all SAX handlers in some way? 
Otherwise, we will need to check the ID maps of all SAX handlers for 
duplicate IDs and when looking up an object via an IDREF.  The map of 
IDREFs, on the other hand, could be local to the SAX handler I think.

I don't know how to handle elements of type ID.  This isn't really 
relevant for my use at least, not even sure if it really makes sense. 
Anyway, if I have an element declared as

<xs:schema targetNamespace="http://www.clixml.org/clix/1.0"
[...]
     <xs:complexType>
       <xs:sequence>
         <xs:element name="id" type="xs:ID"/>
[...]

then the type ('childType' in GroupHandlerSG.handleEndElementState) of 
the element is the namespace URI ("http://www.clixml.org/clix/1.0") and 
local name ("id") of the element.  How do you retrieve the actual type 
of the element declared in the schema?

I've also attached the schema I'm interested in compiling with JaxMe, in 
case you are interested.


Best regards,

Fredrik Vraalsen
SINTEF

Re: IDREF and xjc:dom

Posted by Jochen Wiedmann <jo...@gmail.com>.
Hi, Fredrik,

both things shouldn't be technically too difficult. I'll start with
the ID/IDREF thing, we may return to the xjc:dom implementation later.

Forgetting for a moment, that the actual bean classes need changes,
I'll suggest that we start with validating the IDREF's. We'll later
see, that this is actually most of the work, if we do it right.

If an object has embedded ID/IDREF's, then its generated SAX handler
needs two additional objects:

  - A Map for storing the ID's and and the elements, to which are
being mapped. An
    element is added to this Map, whenever the SAX handler detects an
ID. The Map
    keys are the ID's and the Map elements are the associated elements.
  - A List for storing the IDREF's. Whenever the SAX handler detects
an IDREF, then
    it adds an implementation of the interface

            interface IDREF {
                void validate(Map pIds) throws SAXException;
            }

    The idea is, that the SAX handler will invoke all the IDREF's
within endDocument().
    Obviously, if the IDREF implementation is a suitable inner class,
then it can not
    only validate the reference, but invoke a proper setter as well.

For that first step, you should be able to work within the class
DriverSGImpl and its subclasses only, so a deeper understanding of all
the JaxMe details shouldn't be required.


In any case, regards for the hint, that we do not meet the SPEC's in
that particular point.


Jochen


-- 
What are the first steps on the moon, compared to your child's?

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org