1 package com.thaiopensource.relaxng.impl;2 3 import org.relaxng.datatype.Datatype;4 import org.relaxng.datatype.DatatypeBuilder;5 import org.relaxng.datatype.DatatypeException;6 import org.relaxng.datatype.DatatypeLibrary;7 import org.relaxng.datatype.DatatypeLibraryFactory;8 import com.thaiopensource.xml.util.WellKnownNamespaces;9 10 class CompatibilityDatatypeLibrary implements DatatypeLibrary {11 private final DatatypeLibraryFactory factory;12 private DatatypeLibrary xsdDatatypeLibrary = null;13 14 CompatibilityDatatypeLibrary(DatatypeLibraryFactory factory) {15 this.factory = factory;16 }17 18 public DatatypeBuilder createDatatypeBuilder(String type)19 throws DatatypeException {20 if (type.equals("ID") || type.equals("IDREF") || type.equals("IDREFS")) {21 if (xsdDatatypeLibrary == null) {22 xsdDatatypeLibrary = factory.createDatatypeLibrary(WellKnownNamespaces.XML_SCHEMA_DATATYPES);23 if (xsdDatatypeLibrary == null)24 throw new DatatypeException();25 }26 return xsdDatatypeLibrary.createDatatypeBuilder(type);27 }28 throw new DatatypeException();29 }30 31 public Datatype createDatatype(String type) throws DatatypeException {32 return createDatatypeBuilder(type).createDatatype();33 }34 }35