[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-user
Subject:    RE: type related question (long)
From:       "Radu Preotiuc-Pietro" <radup () bea ! com>
Date:       2008-04-24 20:32:17
Message-ID: BF6B6CA032BA0A429BD924F96765147DBF2F06 () repbex02 ! amer ! bea ! com
[Download RAW message or body]

You need to use the XmlObject.substitute(QName, SchemaType) method to
let XMLBeans know you want to use substitution groups. Something along
the lines of:

newfeature.substitute(new QName("http://earth.google.com/kml/2.1",
"Document"), DocumentType.type);

Radu

> -----Original Message-----
> From: Raif S. Naffah [mailto:raif@forge.com.au] 
> Sent: Wednesday, April 09, 2008 12:07 AM
> To: user@xmlbeans.apache.org
> Subject: xsi:type related question (long)
> 
> hello all,
> 
> using version 2.3.0 i created the Java Binding classes for kml version
> 2.1 (http://code.google.com/apis/kml/schema/kml21.xsd).  
> parsing a kml document similar to the following is ok:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <kml xmlns="http://earth.google.com/kml/2.1">
> <Document>
> <name>Document.kml</name>
> <open>1</open>
> <Style id="exampleStyleDocument">
> <LabelStyle>
> <color>ff0000cc</color>
> </LabelStyle>
> </Style>
> <Placemark>
> <name>Document Feature 1</name>
> <styleUrl>#exampleStyleDocument</styleUrl>
> <Point>
> <coordinates>-122.371,37.816,0</coordinates>
> </Point>
> </Placemark>
> <Placemark>
> <name>Document Feature 2</name>
> <styleUrl>#exampleStyleDocument</styleUrl>
> <Point>
> <coordinates>-122.370,37.817,0</coordinates>
> </Point>
> </Placemark>
> </Document>
> </kml>
> 
> on the other hand, constructing a similar document and saving 
> it through the generated classes, with an XmlOptions instance 
> set as follows:
> 
> ...
> setSaveNamespacesFirst();
> setSavePrettyPrint();
> setSavePrettyPrintIndent(2);
> setSaveAggressiveNamespaces();
> final Map<String,String> implicitNamespaces = new 
> HashMap<String,String>();
> implicitNamespaces.put(
> "xsi", "http://www.w3.org/2001/XMLSchema-instance");
> setSaveImplicitNamespaces(implicitNamespaces);
> setUseDefaultNamespace();
> ...
> 
> end up with the following XML:
> 
> <kml xmlns="http://earth.google.com/kml/2.1">
> <Feature xmlns:ns="http://earth.google.com/kml/2.1" 
> xsi:type="ns:DocumentType">
> <name>Document.kml</name>
> <open>true</open>
> <StyleSelector id="exampleStyleDocument" xsi:type="ns:StyleType">
> <LabelStyle>
> <color>FF0000CC</color>
> </LabelStyle>
> </StyleSelector>
> <Feature xsi:type="ns:PlacemarkType">
> <name>Document Feature 1</name>
> <styleUrl>#exampleStyleDocument</styleUrl>
> <Geometry xsi:type="ns:PointType">
> <coordinates>-122.371,37.817</coordinates>
> </Geometry>
> </Feature>
> <Feature xsi:type="ns:PlacemarkType">
> <name>Document Feature 2</name>
> <styleUrl>#exampleStyleDocument</styleUrl>
> <Geometry xsi:type="ns:PointType">
> <coordinates>-122.37,37.817</coordinates>
> </Geometry>
> </Feature>
> </Feature>
> </kml>
> 
> what i'd like to get when saving the KmlDocument instance is 
> something close to the first version.
> 
> is this possible?  how?
> 
> 
> TIA + cheers;
> rsn
> 

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: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic