Hi,

I will have a look at this in detail later on tonight.

Werner

philipp_s wrote:
> in other words:
> I am still running into an issue creating an inner (anonymous) complex type
> like in the schema above:
> 
> for simpleTypes I can do it like that: 
> 
> elementType = schema.createSimpleType(null,
> simpleTypesFactory.getBuiltInType(simpleTypesFactory
>                     .getBuiltInTypeName(SimpleTypesFactory.STRING_TYPE)));
> 
> but when creating a complex type like:
> 
>                complexElementType = schema.createComplexType(null);           
>     
>                 AttributeGroupReference propertyAttributes = new
> AttributeGroupReference(productTypes, "foo:stringAttributes");
>                 complexElementType.setBaseType(elementType);
>                
> complexElementType.addAttributeGroupReference(propertyAttributes);
>  
> 
> (the same is true for complexElementType = schema.createComplexType(); )
> 
> later in the code:
> ElementDecl property = new ElementDecl(schema, localName);
> 
>         if (complexElementType == null) {
>             property.setType(elementType);    
> ...      
>         } else {
>             property.setType(complexElementType);           
> ...
>         }
> 
> I always get a null pointer exception when writing the schema...
> 
> testSchemaCreation(com.bla.BlaSchemaGeneratorMojoTest)  Time elapsed: 3.264
> sec  <<< ERROR!
> java.lang.NullPointerException
>         at
> org.exolab.castor.xml.schema.writer.SchemaWriter.processComplexType(SchemaWriter.java:579)
>         at
> org.exolab.castor.xml.schema.writer.SchemaWriter.processElement(SchemaWriter.java:882)
>         at
> org.exolab.castor.xml.schema.writer.SchemaWriter.processContentModelGroup(SchemaWriter.java:694)
>         at
> org.exolab.castor.xml.schema.writer.SchemaWriter.processGroup(SchemaWriter.java:975)
>         at
> org.exolab.castor.xml.schema.writer.SchemaWriter.processContentModelGroup(SchemaWriter.java:698)
>         at
> org.exolab.castor.xml.schema.writer.SchemaWriter.processComplexType(SchemaWriter.java:654)
>         at
> org.exolab.castor.xml.schema.writer.SchemaWriter.processSchema(SchemaWriter.java:1256)
>         at
> org.exolab.castor.xml.schema.writer.SchemaWriter.write(SchemaWriter.java:214)
>         at
> com.bla.BlaSchemaGeneratorMojo.writeSchemaFile(BlaSchemaGeneratorMojo.java:1005)
> 
> 
> thx,
> 
> Philipp 
> 
> 
> 
> philipp_s wrote:
>> hmm, I am still stuck, I need to add some facets in the generated schema,
>> and therefore cannot just simple reference the type from the other schema,
>>
>> it seems I need to do something like this in the generated schema:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <schema xmlns="http://www.w3.org/2001/XMLSchema";
>> xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
>>         targetNamespace="http://foo/barGenerated";
>> xmlns:fooGenerated="http://foo/barGenerated";
>>         xmlns:foo="http://foo/bar"; elementFormDefault="qualified"
>> version="1.0">
>>   <xs:import namespace="http://foo/bar"; />
>>   
>>   <xs:element name="bla">
>>     <xs:complexType>
>>       <xs:simpleContent>
>>         <xs:extension base="fooGenerated:blaBaseType">
>>           <xs:attributeGroup ref="foo:stringAttributes" />
>>         </xs:extension>
>>       </xs:simpleContent>
>>     </xs:complexType>
>>   </xs:element>
>>
>>   <xs:simpleType name="blaBaseType">
>>     <xs:restriction base="xs:string">
>>       <xs:pattern value="[0-3][0-9]-[A-Za-z]{3}-[1|2][0-9]{3}" />
>>     </xs:restriction>
>>   </xs:simpleType>
>>   
>> </schema>
>>
>> where the attributeGroup is located in a pre-existing schema
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
>> targetNamespace="http://foo/bar"; attributeFormDefault="unqualified"
>>   elementFormDefault="qualified" version="1.0">
>>
>>   <xs:attributeGroup name="stringAttributes">
>>     <xs:attribute name="lang" type="xs:string" use="optional" />
>>     <xs:attribute name="index" type="xs:int" use="optional" default="1" />
>>   </xs:attributeGroup>
>>
>> </xs:schema>
>>
>> I now have the problem that I don't know how to create a anonymous
>> complexType for the element definition - any help would be appreciated...
>>
>> thx,
>>
>> Philipp
>>
>>
>> philipp_s wrote:
>>> Hi Werner,
>>>
>>> let's assume we have a schema like this, containing an attribute group
>>> definition:
>>>
>>>     <?xml version="1.0" encoding="UTF-8"?>
>>>     <schema xmlns="http://www.w3.org/2001/XMLSchema";
>>> xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
>>>       targetNamespace="http://foo/bar"; elementFormDefault="qualified"
>>> version="1.0">  
>>>       <xs:attributeGroup name="someAttributes">
>>>         <xs:attribute name="index" type="xs:string" use="optional"
>>> default="1" />
>>>         <xs:attribute name="lang" type="xs:string" use="optinal" />
>>>       </xs:attributeGroup>
>>>     </Schema>
>>>     
>>> now I want to programmatically generate a schema that uses the attribute
>>> group for an element definition based on the xs:string, it should look
>>> something like this:
>>>     
>>>     <?xml version="1.0" encoding="UTF-8"?>
>>>     <schema xmlns="http://www.w3.org/2001/XMLSchema";
>>> xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
>>>       targetNamespace="http://foo/barGenerated";
>>> xmlns:foo="http://foo/bar"; elementFormDefault="qualified" version="1.0">  
>>>       <xs:element name="bla">
>>>         <xs:complexType>
>>>           <xs:simpleContent>
>>>             <xs:restriction base="xs:string"></xs:restriction>
>>>           </xs:simpleContent>
>>>           <xs:attributeGroup ref="foo:someAttributes" />
>>>         </xs:complexType>
>>>       </xs:element>  
>>>     </schema>
>>>
>>> But it seems that doesn't work at all, so now I reverted to declare not
>>> an attributeGroup but an element type in the pre-existing schema:
>>>
>>>   <xs:complexType name="fooType">
>>>     <xs:simpleContent>
>>>       <xs:extension base="xs:string">
>>>         <xs:attribute name="lang" type="xs:string" use="optional" />
>>>         <xs:attribute name="index" type="xs:int" use="optional"
>>> default="1" />
>>>       </xs:extension>
>>>     </xs:simpleContent>
>>>   </xs:complexType>
>>>
>>> and reference that in the generated schema.
>>>
>>>
>>> thx,
>>>
>>> Philipp
>>>
>>>
>>> Werner Guttmann wrote:
>>>> Hi,
>>>>
>>>> can you show me one ro two example of the (anonymuous) type definitions
>>>> you'd like to create ?
>>>>
>>>> Thanks
>>>> Werner
>>>>
>>>> philipp_s wrote:
>>>>> When programmatically creating a schema using castor, I now need to add
>>>>> an
>>>>> attributeGroup to an element (type) declaration - how can I do that? 
>>>>>
>>>>> thx,
>>>>>
>>>>> Philipp
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>     http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>>
>>>
>>
> 

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to