You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Ramin Roham-Pour <rr...@ip-value.de> on 2006/02/06 14:52:38 UTC

parsing global types

Hi!

I have a little problem in handling instances of global types generated
by parsing an xml-string.

In my schema there is defined an element containing a complex type,
which is itself a global type in this schema. When I parse a xml-string
to this complex type everything looks fine until I set this instance of
the complex type as the one in an instance of the element. In the
element the complex type is nested into another instance of the complex
type and seems not to be recognized as a complex type, but as additional
data not defined in the schema.
If I replace the name of the complex type in the xml-string with
"xml-fragment" before parsing, the above described does not happen,
instead everything works fine again until I compare this instance of
complex type to another instance. The comparison fails because the name
of the instance is not the same, it is still xml-fragment...

So for the moment I have to decide which of these problems I have to
work around, but I really would prefer to know how to handle these
correctly.
My best way to avoid this is to write complete elements, parse those and
extract the complex types from them, but thats not really perfect, too.

Thanks in advance for helping
Ramin


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: parsing global types

Posted by Ramin Roham-Pour <rr...@ip-value.de>.
Hi!

Seems like my mail got lost somehow, so I try again now.

My problem:
When I parse the troubleticketvalue everything looks fine, until I add
it to the createTroubleTicketByValueRequest. If I do so the value is
placed into another troubleTicketValue-tag. This does not happen when I
replace the name of the topmost tag in the troubleTicketValue with
"xml-fragment", but then the name of the tag is not troubleTicketValue
when I get it back from the request to compare it.

My code:


String troubleTicketValue = loadXML("PPTTValue.xml");
CreateTroubleTicketByValueRequestDocument createReq = null;
TroubleTicketValue valuedoc = null;
try{
createReq =
CreateTroubleTicketByValueRequestDocument.Factory.newInstance();
valuedoc = TroubleTicketValue.Factory.parse(troubleTicketValue);
}catch(Exception e){
log.error("Exception while parsing document: " + e.toString());
fail("Exception while parsing document: " + e.toString());
}


createReq.addNewCreateTroubleTicketByValueRequest().setTroubleTicketValue(valuedoc);
String createRequest = createReq.toString();

The PPTTValue.xml:
<troubleTicketValue
xsi:schemaLocation="http://java.sun.com/products/oss/xml/TroubleTicket
XmlTroubleTicketSchema.xsd" xsi:type="tt:TroubleTicketValue">
<co:lastUpdateVersionNumber>0</co:lastUpdateVersionNumber>
<tt:originator>Max Mustermann</tt:originator>
<tt:receivedTime>2004-12-23T00:00:00.0</tt:receivedTime>
<tt:troubleDescription>Fehlerbeschreibung</tt:troubleDescription>
<tt:troubledObject>defektes Ger�t</tt:troubledObject>
<tt:troubleState>OPENACTIVE</tt:troubleState>
<tt:troubleStatus>SCREENING</tt:troubleStatus>
<tt:preferredPriority>MINOR</tt:preferredPriority>
</troubleTicketValue>

Please find the schema at:

http://java.sun.com/products/oss/xml/TroubleTicket/XmlTroubleTicketSchema.xsd
Regarding its size this might be easier for all than attaching it.

Ramin


Am Mo 06.02.2006 15:56 schrieb Edward Frederick <ep...@gmail.com>:

> Ramin,
> 
> Could you provide the schema, a sample of the XML you are parsing, and
> a snippet of the code that you're using to instantiate your
> XMLBean(s)? It may be easier for someone to help with more
> information. I have a suspicion, but It'd like to see some snippets to
> confirm it.
> 
> 
> Ed
> 
> 
> On 2/6/06, Ramin Roham-Pour <rr...@ip-value.de> wrote:
> > Hi!
> >
> > I have a little problem in handling instances of global types
> > generated
> > by parsing an xml-string.
> >
> > In my schema there is defined an element containing a complex type,
> > which is itself a global type in this schema. When I parse a
> > xml-string
> > to this complex type everything looks fine until I set this instance
> > of
> > the complex type as the one in an instance of the element. In the
> > element the complex type is nested into another instance of the
> > complex
> > type and seems not to be recognized as a complex type, but as
> > additional
> > data not defined in the schema.
> > If I replace the name of the complex type in the xml-string with
> > "xml-fragment" before parsing, the above described does not happen,
> > instead everything works fine again until I compare this instance of
> > complex type to another instance. The comparison fails because the
> > name
> > of the instance is not the same, it is still xml-fragment...
> >
> > So for the moment I have to decide which of these problems I have to
> > work around, but I really would prefer to know how to handle these
> > correctly.
> > My best way to avoid this is to write complete elements, parse those
> > and
> > extract the complex types from them, but thats not really perfect,
> > too.
> >
> > Thanks in advance for helping
> > Ramin
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: parsing global types

Posted by Edward Frederick <ep...@gmail.com>.
Ramin,

Could you provide the schema, a sample of the XML you are parsing, and
a snippet of the code that you're using to instantiate your
XMLBean(s)? It may be easier for someone to help with more
information. I have a suspicion, but It'd like to see some snippets to
confirm it.


Ed


On 2/6/06, Ramin Roham-Pour <rr...@ip-value.de> wrote:
> Hi!
>
> I have a little problem in handling instances of global types generated
> by parsing an xml-string.
>
> In my schema there is defined an element containing a complex type,
> which is itself a global type in this schema. When I parse a xml-string
> to this complex type everything looks fine until I set this instance of
> the complex type as the one in an instance of the element. In the
> element the complex type is nested into another instance of the complex
> type and seems not to be recognized as a complex type, but as additional
> data not defined in the schema.
> If I replace the name of the complex type in the xml-string with
> "xml-fragment" before parsing, the above described does not happen,
> instead everything works fine again until I compare this instance of
> complex type to another instance. The comparison fails because the name
> of the instance is not the same, it is still xml-fragment...
>
> So for the moment I have to decide which of these problems I have to
> work around, but I really would prefer to know how to handle these
> correctly.
> My best way to avoid this is to write complete elements, parse those and
> extract the complex types from them, but thats not really perfect, too.
>
> Thanks in advance for helping
> Ramin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org