本文整理汇总了Java中com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource类的典型用法代码示例。如果您正苦于以下问题:Java XMLInputSource类的具体用法?Java XMLInputSource怎么用?Java XMLInputSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XMLInputSource类属于com.sun.org.apache.xerces.internal.xni.parser包,在下文中一共展示了XMLInputSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: resolveSchema
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
private Element resolveSchema(XMLInputSource schemaSource, XSDDescription desc,
boolean mustResolve, Element referElement) {
if (schemaSource instanceof DOMInputSource) {
return getSchemaDocument(desc.getTargetNamespace(), (DOMInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
} // DOMInputSource
else if (schemaSource instanceof SAXInputSource) {
return getSchemaDocument(desc.getTargetNamespace(), (SAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
} // SAXInputSource
else if (schemaSource instanceof StAXInputSource) {
return getSchemaDocument(desc.getTargetNamespace(), (StAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
} // StAXInputSource
else if (schemaSource instanceof XSInputSource) {
return getSchemaDocument((XSInputSource) schemaSource, desc);
} // XSInputSource
return getSchemaDocument(desc.getTargetNamespace(), schemaSource, mustResolve, desc.getContextType(), referElement);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:XSDHandler.java
示例2: parseDTD
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
DTDGrammar parseDTD(XMLInputSource is)
throws IOException {
XMLEntityResolver resolver = getEntityResolver();
if(resolver != null) {
fDTDLoader.setEntityResolver(resolver);
}
fDTDLoader.setProperty(ERROR_REPORTER, fErrorReporter);
// Should check whether the grammar with this namespace is already in
// the grammar resolver. But since we don't know the target namespace
// of the document here, we leave such check to the application...
DTDGrammar grammar = (DTDGrammar)fDTDLoader.loadGrammar(is);
// by default, hand it off to the grammar pool
if (grammar != null) {
fGrammarPool.cacheGrammars(XMLGrammarDescription.XML_DTD,
new Grammar[]{grammar});
}
return grammar;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:XMLGrammarCachingConfiguration.java
示例3: validateAnnotations
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
private void validateAnnotations(ArrayList annotationInfo) {
if (fAnnotationValidator == null) {
createAnnotationValidator();
}
final int size = annotationInfo.size();
final XMLInputSource src = new XMLInputSource(null, null, null, false);
fGrammarBucketAdapter.refreshGrammars(fGrammarBucket);
for (int i = 0; i < size; i += 2) {
src.setSystemId((String) annotationInfo.get(i));
XSAnnotationInfo annotation = (XSAnnotationInfo) annotationInfo.get(i+1);
while (annotation != null) {
src.setCharacterStream(new StringReader(annotation.fAnnotation));
try {
fAnnotationValidator.parse(src);
}
catch (IOException exc) {}
annotation = annotation.next;
}
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:XSDHandler.java
示例4: getExternalSubset
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
/**
* <p>Locates an external subset for documents which do not explicitly
* provide one. If no external subset is provided, this method should
* return <code>null</code>.</p>
*
* @param grammarDescription a description of the DTD
*
* @throws XNIException Thrown on general error.
* @throws IOException Thrown if resolved entity stream cannot be
* opened or some other i/o error occurs.
*/
public XMLInputSource getExternalSubset(XMLDTDDescription grammarDescription)
throws XNIException, IOException {
if (fEntityResolver != null) {
String name = grammarDescription.getRootName();
String baseURI = grammarDescription.getBaseSystemId();
// Resolve using EntityResolver2
try {
InputSource inputSource = fEntityResolver.getExternalSubset(name, baseURI);
return (inputSource != null) ? createXMLInputSource(inputSource, baseURI) : null;
}
// error resolving external subset
catch (SAXException e) {
Exception ex = e.getException();
if (ex == null) {
ex = e;
}
throw new XNIException(ex);
}
}
// unable to resolve external subset
return null;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:EntityResolver2Wrapper.java
示例5: createXMLInputSource
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
/**
* Creates an XMLInputSource from a SAX InputSource.
*/
private XMLInputSource createXMLInputSource(InputSource source, String baseURI) {
String publicId = source.getPublicId();
String systemId = source.getSystemId();
String baseSystemId = baseURI;
InputStream byteStream = source.getByteStream();
Reader charStream = source.getCharacterStream();
String encoding = source.getEncoding();
XMLInputSource xmlInputSource =
new XMLInputSource(publicId, systemId, baseSystemId);
xmlInputSource.setByteStream(byteStream);
xmlInputSource.setCharacterStream(charStream);
xmlInputSource.setEncoding(encoding);
return xmlInputSource;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:EntityResolver2Wrapper.java
示例6: resolveExternalSubsetAndRead
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
protected void resolveExternalSubsetAndRead()
throws IOException, XNIException {
fDTDDescription.setValues(null, null, fEntityManager.getCurrentResourceIdentifier().getExpandedSystemId(), null);
fDTDDescription.setRootName(fElementQName.rawname);
XMLInputSource src = fExternalSubsetResolver.getExternalSubset(fDTDDescription);
if (src != null) {
fDoctypeName = fElementQName.rawname;
fDoctypePublicId = src.getPublicId();
fDoctypeSystemId = src.getSystemId();
// call document handler
if (fDocumentHandler != null) {
// This inserts a doctypeDecl event into the stream though no
// DOCTYPE existed in the instance document.
fDocumentHandler.doctypeDecl(fDoctypeName, fDoctypePublicId, fDoctypeSystemId, null);
}
try {
fDTDScanner.setInputSource(src);
while (fDTDScanner.scanDTDExternalSubset(true));
} finally {
fEntityManager.setEntityHandler(XMLDocumentScannerImpl.this);
}
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:XMLDocumentScannerImpl.java
示例7: setInputSource
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
/**
* Sets the input source.
*
* @param inputSource The input source or null.
*
* @throws IOException Thrown on i/o error.
*/
public void setInputSource(XMLInputSource inputSource) throws IOException {
if (inputSource == null) {
// no system id was available
if (fDTDHandler != null) {
fDTDHandler.startDTD(null, null);
fDTDHandler.endDTD(null);
}
if (nonValidatingMode){
nvGrammarInfo.startDTD(null,null);
nvGrammarInfo.endDTD(null);
}
return;
}
fEntityManager.setEntityHandler(this);
fEntityManager.startDTDEntity(inputSource);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:XMLDTDScannerImpl.java
示例8: loadSchema
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
/**
* This method is called either from XMLGrammarLoader.loadGrammar or from XMLSchemaValidator.
* Note: in either case, the EntityManager (or EntityResolvers) are not going to be invoked
* to resolve the location of the schema in XSDDescription
* @param desc
* @param source
* @param locationPairs
* @return An XML Schema grammar
* @throws IOException
* @throws XNIException
*/
SchemaGrammar loadSchema(XSDDescription desc,
XMLInputSource source,
Map locationPairs) throws IOException, XNIException {
// this should only be done once per invocation of this object;
// unless application alters JAXPSource in the mean time.
if(!fJAXPProcessed) {
processJAXPSchemaSource(locationPairs);
}
if (desc.isExternal()) {
String accessError = SecuritySupport.checkAccess(desc.getExpandedSystemId(), faccessExternalSchema, Constants.ACCESS_EXTERNAL_ALL);
if (accessError != null) {
throw new XNIException(fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"schema_reference.access",
new Object[] { SecuritySupport.sanitizePath(desc.getExpandedSystemId()), accessError }, XMLErrorReporter.SEVERITY_ERROR));
}
}
SchemaGrammar grammar = fSchemaHandler.parseSchema(source, desc, locationPairs);
return grammar;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:XMLSchemaLoader.java
示例9: getXMLStreamReaderImpl
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
XMLStreamReader getXMLStreamReaderImpl(XMLInputSource inputSource) throws javax.xml.stream.XMLStreamException{
//1. if the temp reader is null -- create the instance and return
if(fTempReader == null){
fPropertyChanged = false;
return fTempReader = new XMLStreamReaderImpl(inputSource,
new PropertyManager(fPropertyManager));
}
//if factory is configured to reuse the instance & this instance can be reused
//& the setProperty() hasn't been called
if(fReuseInstance && fTempReader.canReuse() && !fPropertyChanged){
if(DEBUG)System.out.println("Reusing the instance");
//we can make setInputSource() call reset() and this way there wont be two function calls
fTempReader.reset();
fTempReader.setInputSource(inputSource);
fPropertyChanged = false;
return fTempReader;
}else{
fPropertyChanged = false;
//just return the new instance.. note that we are not setting fTempReader to the newly created instance
return fTempReader = new XMLStreamReaderImpl(inputSource,
new PropertyManager(fPropertyManager));
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:XMLInputFactoryImpl.java
示例10: validateAnnotations
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
private void validateAnnotations(ArrayList annotationInfo) {
if (fAnnotationValidator == null) {
createAnnotationValidator();
}
final int size = annotationInfo.size();
final XMLInputSource src = new XMLInputSource(null, null, null);
fGrammarBucketAdapter.refreshGrammars(fGrammarBucket);
for (int i = 0; i < size; i += 2) {
src.setSystemId((String) annotationInfo.get(i));
XSAnnotationInfo annotation = (XSAnnotationInfo) annotationInfo.get(i+1);
while (annotation != null) {
src.setCharacterStream(new StringReader(annotation.fAnnotation));
try {
fAnnotationValidator.parse(src);
}
catch (IOException exc) {}
annotation = annotation.next;
}
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:XSDHandler.java
示例11: resolveSchemaSource
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
private XMLInputSource resolveSchemaSource(XSDDescription desc, boolean mustResolve,
Element referElement, boolean usePairs) {
XMLInputSource schemaSource = null;
try {
Map pairs = usePairs ? fLocationPairs : EMPTY_TABLE;
schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityResolver);
}
catch (IOException ex) {
if (mustResolve) {
reportSchemaError("schema_reference.4",
new Object[]{desc.getLocationHints()[0]},
referElement);
}
else {
reportSchemaWarning("schema_reference.4",
new Object[]{desc.getLocationHints()[0]},
referElement);
}
}
return schemaSource;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:XSDHandler.java
示例12: jaxpSourcetoXMLInputSource
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
XMLInputSource jaxpSourcetoXMLInputSource(Source source){
if(source instanceof StreamSource){
StreamSource stSource = (StreamSource)source;
String systemId = stSource.getSystemId();
String publicId = stSource.getPublicId();
InputStream istream = stSource.getInputStream();
Reader reader = stSource.getReader();
if(istream != null){
return new XMLInputSource(publicId, systemId, null, istream, null);
}
else if(reader != null){
return new XMLInputSource(publicId, systemId,null, reader, null);
}else{
return new XMLInputSource(publicId, systemId, null);
}
}
throw new UnsupportedOperationException("Cannot create " +
"XMLStreamReader or XMLEventReader from a " +
source.getClass().getName());
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:XMLInputFactoryImpl.java
示例13: preparseGrammar
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
/**
* Parse a grammar from a location identified by an
* XMLInputSource.
* This method also adds this grammar to the XMLGrammarPool
*
* @param type The type of the grammar to be constructed
* @param is The XMLInputSource containing this grammar's
* information
* <strong>If a URI is included in the systemId field, the parser will not expand this URI or make it
* available to the EntityResolver</strong>
* @return The newly created <code>Grammar</code>.
* @exception XNIException thrown on an error in grammar
* construction
* @exception IOException thrown if an error is encountered
* in reading the file
*/
public Grammar preparseGrammar(String type, XMLInputSource
is) throws XNIException, IOException {
if(fLoaders.containsKey(type)) {
XMLGrammarLoader gl = fLoaders.get(type);
// make sure gl's been set up with all the "basic" properties:
gl.setProperty(SYMBOL_TABLE, fSymbolTable);
gl.setProperty(ENTITY_RESOLVER, fEntityResolver);
gl.setProperty(ERROR_REPORTER, fErrorReporter);
// potentially, not all will support this one...
if(fGrammarPool != null) {
try {
gl.setProperty(GRAMMAR_POOL, fGrammarPool);
} catch(Exception e) {
// too bad...
}
}
return gl.loadGrammar(is);
}
return null;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:XMLGrammarPreparser.java
示例14: saxToXMLInputSource
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
private static XMLInputSource saxToXMLInputSource(InputSource sis) {
String publicId = sis.getPublicId();
String systemId = sis.getSystemId();
Reader charStream = sis.getCharacterStream();
if (charStream != null) {
return new XMLInputSource(publicId, systemId, null, charStream,
null);
}
InputStream byteStream = sis.getByteStream();
if (byteStream != null) {
return new XMLInputSource(publicId, systemId, null, byteStream,
sis.getEncoding());
}
return new XMLInputSource(publicId, systemId, null, false);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:XMLSchemaLoader.java
示例15: loadSchema
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
/**
* This method is called either from XMLGrammarLoader.loadGrammar or from XMLSchemaValidator.
* Note: in either case, the EntityManager (or EntityResolvers) are not going to be invoked
* to resolve the location of the schema in XSDDescription
* @param desc
* @param source
* @param locationPairs
* @return An XML Schema grammar
* @throws IOException
* @throws XNIException
*/
SchemaGrammar loadSchema(XSDDescription desc, XMLInputSource source,
Map<String, LocationArray> locationPairs) throws IOException, XNIException {
// this should only be done once per invocation of this object;
// unless application alters JAXPSource in the mean time.
if(!fJAXPProcessed) {
processJAXPSchemaSource(locationPairs);
}
if (desc.isExternal() && !source.isCreatedByResolver()) {
String accessError = SecuritySupport.checkAccess(desc.getExpandedSystemId(), faccessExternalSchema, Constants.ACCESS_EXTERNAL_ALL);
if (accessError != null) {
throw new XNIException(fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"schema_reference.access",
new Object[] { SecuritySupport.sanitizePath(desc.getExpandedSystemId()), accessError }, XMLErrorReporter.SEVERITY_ERROR));
}
}
SchemaGrammar grammar = fSchemaHandler.parseSchema(source, desc, locationPairs);
return grammar;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:XMLSchemaLoader.java
示例16: getSchemaDocument1
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
/**
* Error handling code shared between the various getSchemaDocument() methods.
*/
private Element getSchemaDocument1(boolean mustResolve, boolean hasInput,
XMLInputSource schemaSource, Element referElement, IOException ioe) {
// either an error occured (exception), or empty input source was
// returned, we need to report an error or a warning
if (mustResolve) {
if (hasInput) {
reportSchemaError("schema_reference.4",
new Object[]{schemaSource.getSystemId()},
referElement, ioe);
}
else {
reportSchemaError("schema_reference.4",
new Object[]{schemaSource == null ? "" : schemaSource.getSystemId()},
referElement, ioe);
}
}
else if (hasInput) {
reportSchemaWarning("schema_reference.4",
new Object[]{schemaSource.getSystemId()},
referElement, ioe);
}
fLastSchemaWasDuplicate = false;
return null;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:XSDHandler.java
示例17: resolveSchemaSource
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
private XMLInputSource resolveSchemaSource(XSDDescription desc, boolean mustResolve,
Element referElement, boolean usePairs) {
XMLInputSource schemaSource = null;
try {
Map<String, XMLSchemaLoader.LocationArray> pairs = usePairs ? fLocationPairs : Collections.emptyMap();
schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityManager);
}
catch (IOException ex) {
if (mustResolve) {
reportSchemaError("schema_reference.4",
new Object[]{desc.getLocationHints()[0]},
referElement);
}
else {
reportSchemaWarning("schema_reference.4",
new Object[]{desc.getLocationHints()[0]},
referElement);
}
}
return schemaSource;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:XSDHandler.java
示例18: loadURI
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
/**
* Parse an XML Schema document from a location identified by a URI
* reference. If the URI contains a fragment identifier, the behavior is
* not defined by this specification.
* @param uri The location of the XML Schema document to be read.
* @return An XSModel representing this schema.
*/
public XSModel loadURI(String uri) {
try {
fGrammarPool.clear();
return ((XSGrammar) fSchemaLoader.loadGrammar(new XMLInputSource(null, uri, null, false))).toXSModel();
}
catch (Exception e){
fSchemaLoader.reportDOMFatalError(e);
return null;
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:XSLoaderImpl.java
示例19: loadGrammarWithContext
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
/**
* Parse a DTD internal and/or external subset and insert the content
* into the existing DTD grammar owned by the given DTDValidator.
*/
public void loadGrammarWithContext(XMLDTDValidator validator, String rootName,
String publicId, String systemId, String baseSystemId, String internalSubset)
throws IOException, XNIException {
final DTDGrammarBucket grammarBucket = validator.getGrammarBucket();
final DTDGrammar activeGrammar = grammarBucket.getActiveGrammar();
if (activeGrammar != null && !activeGrammar.isImmutable()) {
fGrammarBucket = grammarBucket;
fEntityManager.setScannerVersion(getScannerVersion());
reset();
try {
// process internal subset
if (internalSubset != null) {
// To get the DTD scanner to end at the right place we have to fool
// it into thinking that it reached the end of the internal subset
// in a real document.
StringBuffer buffer = new StringBuffer(internalSubset.length() + 2);
buffer.append(internalSubset).append("]>");
XMLInputSource is = new XMLInputSource(null, baseSystemId,
null, new StringReader(buffer.toString()), null);
fEntityManager.startDocumentEntity(is);
fDTDScanner.scanDTDInternalSubset(true, false, systemId != null);
}
// process external subset
if (systemId != null) {
XMLDTDDescription desc = new XMLDTDDescription(publicId, systemId, baseSystemId, null, rootName);
XMLInputSource source = fEntityManager.resolveEntity(desc);
fDTDScanner.setInputSource(source);
fDTDScanner.scanDTDExternalSubset(true);
}
}
catch (EOFException e) {
// expected behaviour...
}
finally {
// Close all streams opened by the parser.
fEntityManager.closeReaders();
}
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:44,代码来源:XMLDTDLoader.java
示例20: loadURIList
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; //导入依赖的package包/类
/**
* Parses the content of XML Schema documents specified as the list of URI
* references. If the URI contains a fragment identifier, the behavior
* is not defined by this specification.
* @param uriList The list of URI locations.
* @return An XSModel representing the schema documents.
*/
public XSModel loadURIList(StringList uriList) {
int length = uriList.getLength();
try {
fGrammarPool.clear();
for (int i = 0; i < length; ++i) {
fSchemaLoader.loadGrammar(new XMLInputSource(null, uriList.item(i), null, false));
}
return fGrammarPool.toXSModel();
}
catch (Exception e) {
fSchemaLoader.reportDOMFatalError(e);
return null;
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:XSLoaderImpl.java
注:本文中的com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论