From: <jde...@sv...> - 2006-10-31 04:34:16
|
Author: jdeolive Date: 2006-10-30 20:32:29 -0800 (Mon, 30 Oct 2006) New Revision: 22489 Modified: geotools/trunk/gt/modules/extension/xml-xsd/src/main/java/org/geotools= /xml/impl/ElementHandlerImpl.java Log: added for property check for parsing attributes of unknown type Modified: geotools/trunk/gt/modules/extension/xml-xsd/src/main/java/org/g= eotools/xml/impl/ElementHandlerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- geotools/trunk/gt/modules/extension/xml-xsd/src/main/java/org/geotool= s/xml/impl/ElementHandlerImpl.java 2006-10-31 04:32:00 UTC (rev 22488) +++ geotools/trunk/gt/modules/extension/xml-xsd/src/main/java/org/geotool= s/xml/impl/ElementHandlerImpl.java 2006-10-31 04:32:29 UTC (rev 22489) @@ -17,11 +17,15 @@ =20 import org.eclipse.xsd.XSDAttributeDeclaration; import org.eclipse.xsd.XSDElementDeclaration; +import org.eclipse.xsd.XSDFactory; import org.eclipse.xsd.XSDSchemaContent; +import org.eclipse.xsd.XSDSimpleTypeDefinition; +import org.eclipse.xsd.util.XSDUtil; import org.geotools.xml.AttributeInstance; import org.geotools.xml.Binding; import org.geotools.xml.BindingFactory; import org.geotools.xml.InstanceComponent; +import org.geotools.xml.Parser; import org.geotools.xml.SchemaIndex; import org.geotools.xml.Schemas; import org.picocontainer.defaults.DefaultPicoContainer; @@ -89,6 +93,23 @@ XSDAttributeDeclaration decl =3D Schemas.getAttributeDeclara= tion(content, attQName); =20 + if ( decl =3D=3D null ) { + //check wether unknown attributes should be parsed + if ( parent.getContext().getComponentInstance( Parser.Prope= rties.PARSE_UNKNOWN_ATTRIBUTES ) !=3D null ) { + //create a mock attribute and continue + decl =3D XSDFactory.eINSTANCE.createXSDAttributeDeclaratio= n(); + decl.setName( attQName.getLocalPart() ); + decl.setTargetNamespace( attQName.getNamespaceURI() ); + =09 + //set the type to be of string + XSDSimpleTypeDefinition type =3D (XSDSimpleTypeDefinition)= =20 + XSDUtil.getSchemaForSchema( XSDUtil.SCHEMA_FOR_SCHEMA_URI= _2001 ) + .getSimpleTypeIdMap().get( "string" ); + =09 + decl.setTypeDefinition( type ); + } + } + =20 //TODO: validate, if there is no declaration for an attribut= e, then=20 //TODO: make sure no required attributes are missing // validation should fail, this is being side stepped for no= w until @@ -103,10 +124,9 @@ =20 atts.add(att); } - - // else { - // parser.getLogger().warning("Could not find attribute d= eclaration: " + attQName); - // } + else { + parser.getLogger().warning("Could not find attribute declaration: " = + attQName); + } } =20 //create the element |