Yes, my XML is
<element uri="www.apache.org"/>
Radu
________________________________
From: Pascal Maugeri [mailto:[EMAIL PROTECTED]
Sent: Monday, April 28, 2008 11:55 PM
To: [email protected]
Subject: Re: Parsing an XML fragment
Thanks to both for your answers and suggestions. It's getting
clearer to me...
Radu, what is the content of this file test.xml in your test ? I
guess only <element/> ?
Remember, I have only the schema (and the corresponding beans)
then I receive this fragment <element/> that I want to parse.
Regards,
Pascal
On Tue, Apr 29, 2008 at 2:27 AM, Radu Preotiuc-Pietro
<[EMAIL PROTECTED]> wrote:
Actually, I have made some experiments myself and you
may have success
with something like:
DocDocument.Doc doc = (DocDocument.Doc)
XmlObject.Factory.parse(new
File("test.xml"), new
XmlOptions().setDocumentType(DocDocument.Doc.type));
to parse from the <element> level.
Let me know if this works for you,
Radu
> -----Original Message-----
> From: Jim the Standing Bear
[mailto:[EMAIL PROTECTED]
> Sent: Monday, April 28, 2008 8:38 AM
> To: [email protected]
> Subject: Re: Parsing an XML fragment
>
> I ran into the same problem and toyed around it over
the weekend.
> what I found out was that it helps if you parse it
from "a level up".
>
> So in your case, you would have to parse it from the
Document
> level, since that is the only thing above "Element"
nodes.
>
> In other words, doing
> Doc.Factory.parse(xml).getDoc().getElement().getUri()
is the
> way to go. However, you said you needed to parse from
> Element level - is there any constraints that force
you to
> parse from Element level?
>
> HTH
>
> Jim
>
>
>
> On Mon, Apr 28, 2008 at 6:17 AM, Pascal Maugeri
> <[EMAIL PROTECTED]> wrote:
> > Radu
> >
> > You're right in the example below the <element> is
not a
> global schema type.
> >
> > So what should I do if a server (XCAP server) sends
me this
> XML fragment:
> >
> >
> > <element uri="www.apache.org"/>
> >
> > and I want to parse it having the xml beans set from
the
> corresponding
> > schema ?
> >
> > Is there a way to do that ?
> >
> > Regards,
> > Pascal
> >
> >
> >
> >
> > On Sat, Apr 19, 2008 at 3:35 AM, Radu
Preotiuc-Pietro
> <[EMAIL PROTECTED]> wrote:
> >
> > > I'd have to see the Schema to be able to figure
out the name of
> > > elements and types and what the exact code should
look
> like. I think
> > > that your problem might be that <element> is not a
global Schema
> > > type and so auto-typing doesn't work if at the
root level
> (in other
> > > words, Schema doesn't allow <element> to be a
top-level element).
> > >
> > > But even then, you should not have to parse and
save to
> String only
> > > to parse again.
> > >
> > > Radu
> > >
> > >
> > >
> > >
> > > On Tue, 2008-04-08 at 06:49 -0700, Pascal Maugeri
wrote:
> > > > Hi
> > > >
> > > > I would like to have a clarification about the
parsing of a XML
> > > > fragment.
> > > >
> > > > For instance, having the following XML document,
I want
> to obtain
> > > > the "uri" attribute value:
> > > >
> > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > <doc>
> > > > <element uri="www.apache.org"/>
> > > > </doc>
> > > >
> > > > with
> > > >
Doc.Factory.parse(xml).getDoc().getElement().getUri()
> > > > it returns the attribute value.
> > > >
> > > > but with
> > > > Element.Factory.parse("<element
> > > > uri=\"www.apache.org\"/>").getUri()
> > > > it returns null, also a call to
Element.Factory.parse("<element
> > > > uri=
> > > > \"www.apache.org\"/>").toString() returns the
XML content.
> > > >
> > > > As I do need to parse XML fragment such as this
> "element", I have
> > > > found the following workaround:
> > > > a) I get the String representation of the
Element (eg.
> > > > Element.Factory.parse(...).toString() ),
> > > > b) I insert the result of (a) into a container
<doc>...</doc>
> > > > c) then I parse the result of (b) with the
> Doc.Factory.parse( (b)
> > > > ).getDoc().getElement().getUri() and it does
work.
> > > > ... also I'm not very proud of myself :-)
> > > >
> > > > Could you explain why I can't access the
attributes of a XML
> > > > fragment I parsed ?
> > > >
> > > > I there a better/cleaner workaround than the one
above ?
> > > >
> > > > Thanks in advance for your help
> > > > Pascal
> > >
> > > Notice: This email message, together with any
attachments, may
> > > contain
> > information of BEA Systems, Inc., its
subsidiaries and
> > affiliated entities, that may be confidential,
proprietary,
> > copyrighted and/or legally privileged, and is
intended
> solely for the
> > use of the individual or entity named in this
message. If
> you are not
> > the intended recipient, and have received this
message in error,
> > please immediately return this by email and then
delete it.
> > >
> > >
>
--------------------------------------------------------------------
> > > - To unsubscribe, e-mail:
[EMAIL PROTECTED]
> > > For additional commands, e-mail:
[EMAIL PROTECTED]
> > >
> > >
> >
> >
>
>
>
> --
> --------------------------------------
> Standing Bear Has Spoken
> --------------------------------------
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
[EMAIL PROTECTED]
> For additional commands, e-mail:
[EMAIL PROTECTED]
>
>
Notice: This email message, together with any
attachments, may contain information of BEA Systems, Inc., its
subsidiaries and affiliated entities, that may be confidential,
proprietary, copyrighted and/or legally privileged, and is intended
solely for the use of the individual or entity named in this message. If
you are not the intended recipient, and have received this message in
error, please immediately return this by email and then delete it.
---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
Notice: This email message, together with any attachments, may contain
information of BEA Systems, Inc., its subsidiaries and affiliated
entities, that may be confidential, proprietary, copyrighted and/or legally
privileged, and is intended solely for the use of the individual or entity
named in this message. If you are not the intended recipient, and have received
this message in error, please immediately return this by email and then delete
it.