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

-- 
View this message in context: 
http://www.nabble.com/programmatic-schema-generation%3A-how-to-add-an-attributeGroup-to-an-element-%28type%29-declaration-tp24147982p24166900.html
Sent from the Castor - User mailing list archive at Nabble.com.


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

    http://xircles.codehaus.org/manage_email


Reply via email to