You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Christopher Hunt <hu...@internode.on.net> on 2008/06/06 14:11:41 UTC

Abstract element with concrete type problem

Hi there,

I'm not sure if this is an xmlbeans issue, or an issue with the xml  
validator I'm using...

I've produced an XML (GML) document which I validate with Java 1.5's  
SchemaFactory for a junit test case. The test case fails and declares:

  The value of {abstract} in the element declaration for  
'ns1:AbstractTimeSlice' must be false.

Here's the xml:

  <AbstractTimeSlice xsi:type="ns:JourneyStatusType" ns1:id="a1">

(I can't use substitution groups because the JourneyStatusType is in a  
different jar to the AbstractTimeSlice...)

Here's the code I use to construct the timeslice:

  AbstractTimeSliceType abstractTimeSliceType =
   historyPropertyType
    .addNewAbstractTimeSlice();

  JourneyStatusType journeyStatusType =
   (JourneyStatusType) abstractTimeSliceType
    .changeType(JourneyStatusType.type);

Thanks for any help.

Cheers,
-C

RE: Abstract element with concrete type problem

Posted by Radu Preotiuc-Pietro <ra...@bea.com>.
Unfortunately, if the element itself is abstract in Schema, you have to
use substitution groups. So the only way to get out of this is for you
to use XmlCursor to change the name of the offending element before you
send it out.
 
Radu


________________________________

	From: Christopher Hunt [mailto:huntc@internode.on.net] 
	Sent: Friday, June 06, 2008 5:12 AM
	To: user@xmlbeans.apache.org
	Subject: Abstract element with concrete type problem
	
	
	Hi there, 

	I'm not sure if this is an xmlbeans issue, or an issue with the
xml validator I'm using...

	I've produced an XML (GML) document which I validate with Java
1.5's SchemaFactory for a junit test case. The test case fails and
declares:

	 The value of {abstract} in the element declaration for
'ns1:AbstractTimeSlice' must be false.

	Here's the xml:

	 <AbstractTimeSlice xsi:type="ns:JourneyStatusType" ns1:id="a1">

	(I can't use substitution groups because the JourneyStatusType
is in a different jar to the AbstractTimeSlice...)

	Here's the code I use to construct the timeslice:

	 AbstractTimeSliceType abstractTimeSliceType = 
	  historyPropertyType
	   .addNewAbstractTimeSlice();

	 JourneyStatusType journeyStatusType = 
	  (JourneyStatusType) abstractTimeSliceType
	   .changeType(JourneyStatusType.type);
	
	
	Thanks for any help.

	Cheers,
	-C


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.

RE: Problem compiling a set of schemas with xmlbeans 2.0.0

Posted by Christopher Hunt <hu...@internode.on.net>.
Hi there,

I was experiencing the same problem even with the latest GML schemas.  
The problem is that GML defines a Pos and a PosList element. xmlbeans  
accordingly declares a getPosList() method twice - once for return a  
list of pos elements, and the other for returning a single posList  
element i.e.

     /**
      * Gets a List of "pos" elements
      */
     public java.util.List<net.opengis.gml.x32.DirectPositionType>  
getPosList()

and

     /**
      * Gets the "posList" element
      */
     public net.opengis.gml.x32.DirectPositionListType getPosList()

...of course there are two identical method signatures with different  
return types. This causes scomp to yield the error:

.../target/generated-sources/net/opengis/gml/x32/impl/ 
LinearRingTypeImpl.java:506: getPosList() is already defined in  
net.opengis.gml.x32.impl.LinearRingTypeImpl
     public net.opengis.gml.x32.DirectPositionListType getPosList()

To avoid this error you have to tell xmlbeans to override one of the  
names. I decided that instead of xmlbeans mapping GML "pos" elements  
to Java "pos" members, they map to "position" instead. To achieve this  
use a command line similar to the following:

scomp -d target/generated-classes/ -src target/generated-sources/ -dl - 
javasource 1.5 -mx 512m src/main/resources/gml.xsd src/main/resources/ 
gml.xsdconfig

and an xsdconfig of:

<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/ 
config"
            xmlns:gml="http://www.opengis.net/gml/3.2">
      <xb:qname name="gml:pos" javaname="Position"/>
</xb:config>

'hope that this helps someone else using xmlbeans with GML.

Cheers,
-C

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


How to suppress generics warnings

Posted by Christopher Hunt <hu...@internode.on.net>.
Hi there,

I'm generating JDK 1.5 xmlbeans source but finding that I'm still  
getting warnings of the nature:

	ArrayList is a raw type. References to generic type ArrayList<E>  
should be parameterized...

In my case, the above can be found in methods like:

         /**
          * Gets array of all "Schedule" elements
          */
         public  
com 
.classactionpl.schemas.flightTimes.TimeTableType.Schedules.Schedule[]  
getScheduleArray()
         {
             synchronized (monitor())
             {
                 check_orphaned();
                 java.util.List targetList = new java.util.ArrayList();
   <snip>

with the last line yielding the warning of course.

I do like to eliminate all project warnings so is there a way I can do  
this? Here's my configuration (specified as a xmlbeans-maven-plugin  
which pretty much maps to the ant task from what I understand):

	<plugin>
		<groupId>org.codehaus.mojo</groupId>
		<artifactId>xmlbeans-maven-plugin</artifactId>
		<version>2.3.1</version>
		<executions>
			<execution>
				<goals>
					<goal>xmlbeans</goal>
				</goals>
			</execution>
		</executions>
		<inherited>true</inherited>
		<configuration>
			<download>true</download>
			<memoryMaximumSize>512m</memoryMaximumSize>
			<schemaDirectory> src/main/resources </schemaDirectory>
			<javaSource>1.5</javaSource>
		</configuration>
	</plugin>
...
	<dependency>
		<groupId>org.apache.xmlbeans</groupId>
		<artifactId>xmlbeans</artifactId>
		<version>2.4.0</version>
	</dependency>

I've also verified that the source produced is indeed for 1.5 and I  
can see other bits of the same source file above that uses generics.

Thanks for any help.

Cheers,
-C

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