Package org.nuxeo.ecm.core.schema
Class XSDLoader
- java.lang.Object
-
- org.nuxeo.ecm.core.schema.XSDLoader
-
public class XSDLoader extends Object
Loader of XSD schemas into Nuxeo Schema objects.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
XSDLoader.NXSchemaResolver
protected static class
XSDLoader.SchemaErrorHandler
-
Field Summary
Fields Modifier and Type Field Description protected boolean
collectReferencedXSD
protected List<String>
referencedXSD
protected SchemaManagerImpl
schemaManager
protected SchemaBindingDescriptor
sd
-
Constructor Summary
Constructors Constructor Description XSDLoader(SchemaManagerImpl schemaManager)
XSDLoader(SchemaManagerImpl schemaManager, boolean collectReferencedXSD)
XSDLoader(SchemaManagerImpl schemaManager, SchemaBindingDescriptor sd)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
collectReferencedXSD(com.sun.xml.xsom.XSSchemaSet xsSchemas)
protected Type
createComplexType(Schema schema, ComplexType superType, String name, com.sun.xml.xsom.XSContentType content, boolean abstractType)
protected Type
createFakeComplexType(Schema schema, ComplexType superType, String name, com.sun.xml.xsom.XSModelGroup mg)
protected static Field
createField(ComplexType type, com.sun.xml.xsom.XSAttributeDecl element, Type fieldType, boolean isNillable)
protected static Field
createField(ComplexType type, com.sun.xml.xsom.XSElementDecl element, Type fieldType)
protected ListType
createListType(Schema schema, String name, com.sun.xml.xsom.XSParticle particle)
protected static ListType
createListType(Schema schema, String name, Type itemType, int min, int max)
protected static String
getAnonymousTypeName(com.sun.xml.xsom.XSType type, String fieldName)
protected ObjectResolverService
getObjectResolverService()
Deprecated.since 11.1.protected com.sun.xml.xsom.parser.XSOMParser
getParser()
List<String>
getReferencedXSD()
protected Type
getType(String name)
protected static String
getTypeName(com.sun.xml.xsom.XSType type, String fieldName)
protected static boolean
isNillable(com.sun.xml.xsom.XSComponent component)
protected static boolean
isNillable(com.sun.xml.xsom.XSElementDecl element)
ignore case where xsd:nillable is recognized as false by xsom (we don't know if it's not specified and we want to preserve a default value to true.protected void
loadAttributes(Schema schema, com.sun.xml.xsom.XSComplexType xsct, ComplexType ct)
protected Type
loadComplexType(Schema schema, String name, com.sun.xml.xsom.XSType type)
protected ListType
loadListType(Schema schema, com.sun.xml.xsom.XSListSimpleType type, String fieldName)
protected Schema
loadSchema(String name, String prefix, com.sun.xml.xsom.XSSchemaSet schemaSet, String xsdElement)
protected Schema
loadSchema(String name, String prefix, com.sun.xml.xsom.XSSchemaSet schemaSet, String xsdElement, boolean isVersionWritable)
Schema
loadSchema(String name, String prefix, File file)
Schema
loadSchema(String name, String prefix, File file, String xsdElement)
Called by schema manager.Schema
loadSchema(String name, String prefix, File file, String xsdElement, boolean isVersionWritable)
Schema
loadSchema(String name, String prefix, URL url)
Schema
loadSchema(String name, String prefix, URL url, String xsdElement)
Create Nuxeo schema from a XSD resource.protected SimpleType
loadSimpleType(Schema schema, com.sun.xml.xsom.XSType type, String fieldName)
protected Type
loadType(Schema schema, com.sun.xml.xsom.XSType type, String fieldName)
protected Type
processModelGroup(Schema schema, ComplexType superType, String name, ComplexType ct, com.sun.xml.xsom.XSModelGroup mg, boolean abstractType)
protected void
registerSchema(Schema schema)
-
-
-
Field Detail
-
schemaManager
protected final SchemaManagerImpl schemaManager
-
collectReferencedXSD
protected boolean collectReferencedXSD
-
sd
protected SchemaBindingDescriptor sd
-
-
Constructor Detail
-
XSDLoader
public XSDLoader(SchemaManagerImpl schemaManager)
-
XSDLoader
public XSDLoader(SchemaManagerImpl schemaManager, SchemaBindingDescriptor sd)
-
XSDLoader
public XSDLoader(SchemaManagerImpl schemaManager, boolean collectReferencedXSD)
-
-
Method Detail
-
getObjectResolverService
@Deprecated protected ObjectResolverService getObjectResolverService()
Deprecated.since 11.1. UseFramework.getService(Class)
withObjectResolverService
instead.
-
registerSchema
protected void registerSchema(Schema schema)
-
getParser
protected com.sun.xml.xsom.parser.XSOMParser getParser()
-
loadSchema
public Schema loadSchema(String name, String prefix, File file) throws SAXException, IOException, TypeException
- Throws:
SAXException
IOException
TypeException
-
loadSchema
public Schema loadSchema(String name, String prefix, File file, String xsdElement) throws SAXException, IOException, TypeException
Called by schema manager.- Throws:
SAXException
IOException
TypeException
- Since:
- 5.7
-
loadSchema
public Schema loadSchema(String name, String prefix, File file, String xsdElement, boolean isVersionWritable) throws SAXException, IOException, TypeException
- Parameters:
isVersionWritable
- if true, the schema's fields will be writable even for Version document.- Throws:
SAXException
IOException
TypeException
- Since:
- 8.4
-
collectReferencedXSD
protected void collectReferencedXSD(com.sun.xml.xsom.XSSchemaSet xsSchemas)
-
loadSchema
public Schema loadSchema(String name, String prefix, URL url, String xsdElement) throws SAXException, TypeException
Create Nuxeo schema from a XSD resource. If xsdElement is non null and correspont to the name of a complex element, the schema is created from the target complex type instead of from the global schema- Parameters:
name
- schema nameprefix
- schema prefixurl
- url to load the XSD resourcexsdElement
- name of the complex element to use as root of the schema- Throws:
SAXException
TypeException
- Since:
- 5.7, 5.7
-
loadSchema
public Schema loadSchema(String name, String prefix, URL url) throws SAXException, TypeException
- Throws:
SAXException
TypeException
-
loadSchema
protected Schema loadSchema(String name, String prefix, com.sun.xml.xsom.XSSchemaSet schemaSet, String xsdElement) throws TypeException
- Throws:
TypeException
- Since:
- 8.4
-
loadSchema
protected Schema loadSchema(String name, String prefix, com.sun.xml.xsom.XSSchemaSet schemaSet, String xsdElement, boolean isVersionWritable) throws TypeException
- Throws:
TypeException
-
loadType
protected Type loadType(Schema schema, com.sun.xml.xsom.XSType type, String fieldName) throws TypeBindingException
- Parameters:
schema
- the nuxeo schema into we register the type.type
- the XSD type to loadfieldName
- the field name owning this type, this is used when type is anonymous/local- Returns:
- the loaded type
- Throws:
TypeBindingException
-
loadComplexType
protected Type loadComplexType(Schema schema, String name, com.sun.xml.xsom.XSType type) throws TypeBindingException
- Parameters:
name
- the type name (note, the type may have a null name if an anonymous type)- Throws:
TypeBindingException
-
loadAttributes
protected void loadAttributes(Schema schema, com.sun.xml.xsom.XSComplexType xsct, ComplexType ct) throws TypeBindingException
- Throws:
TypeBindingException
-
loadSimpleType
protected SimpleType loadSimpleType(Schema schema, com.sun.xml.xsom.XSType type, String fieldName) throws TypeBindingException
- Throws:
TypeBindingException
-
loadListType
protected ListType loadListType(Schema schema, com.sun.xml.xsom.XSListSimpleType type, String fieldName) throws TypeBindingException
- Throws:
TypeBindingException
-
createComplexType
protected Type createComplexType(Schema schema, ComplexType superType, String name, com.sun.xml.xsom.XSContentType content, boolean abstractType) throws TypeBindingException
- Throws:
TypeBindingException
-
createFakeComplexType
protected Type createFakeComplexType(Schema schema, ComplexType superType, String name, com.sun.xml.xsom.XSModelGroup mg) throws TypeBindingException
- Throws:
TypeBindingException
-
processModelGroup
protected Type processModelGroup(Schema schema, ComplexType superType, String name, ComplexType ct, com.sun.xml.xsom.XSModelGroup mg, boolean abstractType) throws TypeBindingException
- Throws:
TypeBindingException
-
createListType
protected ListType createListType(Schema schema, String name, com.sun.xml.xsom.XSParticle particle) throws TypeBindingException
- Throws:
TypeBindingException
-
createListType
protected static ListType createListType(Schema schema, String name, Type itemType, int min, int max)
-
createField
protected static Field createField(ComplexType type, com.sun.xml.xsom.XSElementDecl element, Type fieldType)
-
createField
protected static Field createField(ComplexType type, com.sun.xml.xsom.XSAttributeDecl element, Type fieldType, boolean isNillable)
-
getAnonymousTypeName
protected static String getAnonymousTypeName(com.sun.xml.xsom.XSType type, String fieldName)
-
isNillable
protected static boolean isNillable(com.sun.xml.xsom.XSElementDecl element)
ignore case where xsd:nillable is recognized as false by xsom (we don't know if it's not specified and we want to preserve a default value to true. Therefore, we provide a custom attribute nxs:nillable to force nillable as false) NB: if xsd:nillable is present and sets to true, deducted value will be true even if nxs:nillable is false- Since:
- 7.1
-
isNillable
protected static boolean isNillable(com.sun.xml.xsom.XSComponent component)
-
-