本文整理汇总了Java中com.sun.xml.internal.bind.v2.util.XmlFactory类的典型用法代码示例。如果您正苦于以下问题:Java XmlFactory类的具体用法?Java XmlFactory怎么用?Java XmlFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlFactory类属于com.sun.xml.internal.bind.v2.util包,在下文中一共展示了XmlFactory类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newValidator
import com.sun.xml.internal.bind.v2.util.XmlFactory; //导入依赖的package包/类
public ValidatorHandler newValidator() {
synchronized(this) {
if(schema==null) {
try {
// do not disable secure processing - these are well-known schemas
SchemaFactory sf = XmlFactory.createSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI, false);
schema = allowExternalAccess(sf, "file", false).newSchema(source);
} catch (SAXException e) {
// we make sure that the schema is correct before we ship.
throw new AssertionError(e);
}
}
}
ValidatorHandler handler = schema.newValidatorHandler();
return handler;
}
示例2: ResultImpl
import com.sun.xml.internal.bind.v2.util.XmlFactory; //导入依赖的package包/类
ResultImpl() {
try {
DocumentBuilderFactory factory = XmlFactory.createDocumentBuilderFactory(false); // safe - only used for BI
s2d = new SAX2DOMEx(factory);
} catch (ParserConfigurationException e) {
throw new AssertionError(e); // impossible
}
XMLFilterImpl f = new XMLFilterImpl() {
@Override
public void setDocumentLocator(Locator locator) {
super.setDocumentLocator(locator);
location = new LocatorImpl(locator);
}
};
f.setContentHandler(s2d);
setHandler(f);
}
示例3: checkSchemaCorrectness
import com.sun.xml.internal.bind.v2.util.XmlFactory; //导入依赖的package包/类
/**
* Checks the correctness of the XML Schema documents and return true
* if it's OK.
*
* <p>
* This method performs a weaker version of the tests where error messages
* are provided without line number information. So whenever possible
* use {@link SchemaConstraintChecker}.
*
* @see SchemaConstraintChecker
*/
public boolean checkSchemaCorrectness(ErrorReceiver errorHandler) {
try {
boolean disableXmlSecurity = false;
if (options != null) {
disableXmlSecurity = options.disableXmlSecurity;
}
SchemaFactory sf = XmlFactory.createSchemaFactory(W3C_XML_SCHEMA_NS_URI, disableXmlSecurity);
ErrorReceiverFilter filter = new ErrorReceiverFilter(errorHandler);
sf.setErrorHandler(filter);
Set<String> roots = getRootDocuments();
Source[] sources = new Source[roots.size()];
int i=0;
for (String root : roots) {
sources[i++] = new DOMSource(get(root),root);
}
sf.newSchema(sources);
return !filter.hadError();
} catch (SAXException e) {
// the errors should have been reported
return false;
}
}
示例4: SAX2DOMEx
import com.sun.xml.internal.bind.v2.util.XmlFactory; //导入依赖的package包/类
/**
* Creates a fresh empty DOM document and adds nodes under this document.
* @deprecated
*/
public SAX2DOMEx() throws ParserConfigurationException {
DocumentBuilderFactory factory = XmlFactory.createDocumentBuilderFactory(false);
factory.setValidating(false);
document = factory.newDocumentBuilder().newDocument();
node = document;
nodeStack.push(document);
}
示例5: createTransformer
import com.sun.xml.internal.bind.v2.util.XmlFactory; //导入依赖的package包/类
/**
* Creates a new identity transformer.
*/
static Transformer createTransformer(boolean disableSecureProcessing) {
try {
SAXTransformerFactory tf = (SAXTransformerFactory)XmlFactory.createTransformerFactory(disableSecureProcessing);
return tf.newTransformer();
} catch (TransformerConfigurationException e) {
throw new Error(e); // impossible
}
}
示例6: createTransformerHandler
import com.sun.xml.internal.bind.v2.util.XmlFactory; //导入依赖的package包/类
/**
* Creates a new identity transformer.
*/
public static TransformerHandler createTransformerHandler(boolean disableSecureProcessing) {
try {
SAXTransformerFactory tf = (SAXTransformerFactory)XmlFactory.createTransformerFactory(disableSecureProcessing);
return tf.newTransformerHandler();
} catch (TransformerConfigurationException e) {
throw new Error(e); // impossible
}
}
示例7: createDom
import com.sun.xml.internal.bind.v2.util.XmlFactory; //导入依赖的package包/类
/**
* Creates a new DOM document.
*/
static Document createDom(boolean disableSecurityProcessing) {
synchronized(JAXBContextImpl.class) {
if(db==null) {
try {
DocumentBuilderFactory dbf = XmlFactory.createDocumentBuilderFactory(disableSecurityProcessing);
db = dbf.newDocumentBuilder();
} catch (ParserConfigurationException e) {
// impossible
throw new FactoryConfigurationError(e);
}
}
return db.newDocument();
}
}
示例8: getIdentityTransformer
import com.sun.xml.internal.bind.v2.util.XmlFactory; //导入依赖的package包/类
/**
* Gets the shared instance of the identity transformer.
*/
public Transformer getIdentityTransformer() {
try {
if(identityTransformer==null) {
TransformerFactory tf = XmlFactory.createTransformerFactory(model.options.disableXmlSecurity);
identityTransformer = tf.newTransformer();
}
return identityTransformer;
} catch (TransformerConfigurationException e) {
throw new Error(e); // impossible
}
}
示例9: DOMForest
import com.sun.xml.internal.bind.v2.util.XmlFactory; //导入依赖的package包/类
public DOMForest( InternalizationLogic logic, Options opt ) {
if (opt == null) throw new AssertionError("Options object null");
this.options = opt;
try {
DocumentBuilderFactory dbf = XmlFactory.createDocumentBuilderFactory(opt.disableXmlSecurity);
this.documentBuilder = dbf.newDocumentBuilder();
this.parserFactory = XmlFactory.createParserFactory(opt.disableXmlSecurity);
} catch( ParserConfigurationException e ) {
throw new AssertionError(e);
}
this.logic = logic;
}
示例10: parseAndGetConfig
import com.sun.xml.internal.bind.v2.util.XmlFactory; //导入依赖的package包/类
/**
* Parses an xml config file and returns a Config object.
*
* @param xmlFile
* The xml config file which is passed by the user to annotation processing
* @return
* A non null Config object
*/
private Config parseAndGetConfig (File xmlFile, ErrorHandler errorHandler, boolean disableSecureProcessing) throws SAXException, IOException {
XMLReader reader;
try {
SAXParserFactory factory = XmlFactory.createParserFactory(disableSecureProcessing);
reader = factory.newSAXParser().getXMLReader();
} catch (ParserConfigurationException e) {
// in practice this will never happen
throw new Error(e);
}
NGCCRuntimeEx runtime = new NGCCRuntimeEx(errorHandler);
// set up validator
ValidatorHandler validator = configSchema.newValidator();
validator.setErrorHandler(errorHandler);
// the validator will receive events first, then the parser.
reader.setContentHandler(new ForkContentHandler(validator,runtime));
reader.setErrorHandler(errorHandler);
Config config = new Config(runtime);
runtime.setRootHandler(config);
reader.parse(new InputSource(xmlFile.toURL().toExternalForm()));
runtime.reset();
return config;
}
示例11: newValidator
import com.sun.xml.internal.bind.v2.util.XmlFactory; //导入依赖的package包/类
public ValidatorHandler newValidator() {
if (schema==null) {
synchronized (this) {
if (schema == null) {
ResourceResolver resourceResolver = null;
try (InputStream is = clazz.getResourceAsStream(resourceName)) {
StreamSource source = new StreamSource(is);
source.setSystemId(resourceName);
// do not disable secure processing - these are well-known schemas
SchemaFactory sf = XmlFactory.createSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI, false);
SchemaFactory schemaFactory = allowExternalAccess(sf, "file", false);
if (createResolver) {
resourceResolver = new ResourceResolver(clazz);
schemaFactory.setResourceResolver(resourceResolver);
}
schema = schemaFactory.newSchema(source);
} catch (IOException | SAXException e) {
InternalError ie = new InternalError(e.getMessage());
ie.initCause(e);
throw ie;
} finally {
if (resourceResolver != null) resourceResolver.closeStreams();
}
}
}
}
return schema.newValidatorHandler();
}
示例12: newValidator
import com.sun.xml.internal.bind.v2.util.XmlFactory; //导入依赖的package包/类
public ValidatorHandler newValidator() {
if (schema==null) {
synchronized (this) {
if (schema == null) {
ResourceResolver resourceResolver = null;
try (InputStream is = clazz.getResourceAsStream(resourceName)) {
StreamSource source = new StreamSource(is);
source.setSystemId(resourceName);
// do not disable secure processing - these are well-known schemas
SchemaFactory sf = XmlFactory.createSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI, false);
SchemaFactory schemaFactory = allowExternalAccess(sf, "file", false);
if (createResolver) {
resourceResolver = new ResourceResolver(clazz);
schemaFactory.setResourceResolver(resourceResolver);
}
schema = schemaFactory.newSchema(source);
} catch (IOException | SAXException e) {
throw new InternalError(e);
} finally {
if (resourceResolver != null) resourceResolver.closeStreams();
}
}
}
}
return schema.newValidatorHandler();
}