Schema Imports
adrian.brock Mar 31, 2006 4:19 AMHere's another test, this time imports. :-)
See: org.jboss.test.xml.ExtendedByImportUnitTestCase
I want to extend a type from another schema.
I understand that I need to rebind the type in my schema
that I want to extend, but do I really need to rebind all the other
artifacts from the schema I imported?
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:jboss:test-extended:1.0" xmlns="urn:jboss:test-extended:1.0" xmlns:mc="urn:jboss:bean-deployer:2.0" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0" > <xsd:import namespace="urn:jboss:bean-deployer:2.0"/> <xsd:element name="extended" type="extendedType"/> <xsd:complexType name="extendedType"> <xsd:complexContent> <xsd:extension base="mc:beanType"/> </xsd:complexContent> </xsd:complexType> </xsd:schema>
<extended xmlns="urn:jboss:test-extended:1.0" xmlns:mc="urn:jboss:bean-deployer:2.0" name="TestAspect" class="TestClass"> <mc:property name="testProperty">testString</mc:property> </extended>
If I add the binding for the property to my schema
(the commented code) it works,
but shouldn't it be using the schema bindings from the imported
schema? Rather than forcing me to rebind everything in mine?
public class ExtendedSchemaInitializer implements SchemaBindingInitializer { /** The namespace */ public static final String EXTENDED_NS = "urn:jboss:test-extended:1.0"; /** The extended binding */ private static final QName extendedTypeQName = new QName(EXTENDED_NS, "extendedType"); public SchemaBinding init(SchemaBinding schema) { // extended binding TypeBinding extendedType = schema.getType(extendedTypeQName); BeanSchemaBindingHelper.initBeanHandlers(extendedType); extendedType.setHandler(new BeanHandler() { public Object startElement(Object parent, QName name, ElementBinding element) { return new Extended(); } }); /* TypeBinding propertyType = schema.getType(BeanSchemaBinding20.propertyTypeQName); BeanSchemaBindingHelper.initPropertyHandlers(propertyType); */ return schema; } }