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]
>
>