本文整理汇总了Java中org.apache.xerces.xni.parser.XMLInputSource类的典型用法代码示例。如果您正苦于以下问题:Java XMLInputSource类的具体用法?Java XMLInputSource怎么用?Java XMLInputSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XMLInputSource类属于org.apache.xerces.xni.parser包,在下文中一共展示了XMLInputSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: XSDResolver
import org.apache.xerces.xni.parser.XMLInputSource; //导入依赖的package包/类
private XSDResolver() {
EXISchemaFactory exiSchemaFactory = new EXISchemaFactory();
EXISchemaFactoryExceptionHandler esfe = new EXISchemaFactoryExceptionHandler();
exiSchemaFactory.setCompilerErrorHandler(esfe);
InputStream isV2GCIMsgDef = getClass().getResourceAsStream(GlobalValues.SCHEMA_PATH_MSG_DEF.toString());
XMLInputSource xmlISV2GCIMsgDef = new XMLInputSource(null, null, null, isV2GCIMsgDef, null);
InputStream isV2GCIMsgHeader = getClass().getResourceAsStream(GlobalValues.SCHEMA_PATH_MSG_HEADER.toString());
XMLInputSource xmlISV2GCIMsgHeader = new XMLInputSource(null, null, null, isV2GCIMsgHeader, null);
InputStream isV2GCIMsgBody = getClass().getResourceAsStream(GlobalValues.SCHEMA_PATH_MSG_BODY.toString());
XMLInputSource xmlISV2GCIMsgBody = new XMLInputSource(null, null, null, isV2GCIMsgBody, null);
InputStream isV2GCIMsgDataTypes = getClass().getResourceAsStream(GlobalValues.SCHEMA_PATH_MSG_DATA_TYPES.toString());
XMLInputSource xmlISV2GCIMsgDataTypes = new XMLInputSource(null, null, null, isV2GCIMsgDataTypes, null);
InputStream isXMLDSig = getClass().getResourceAsStream(GlobalValues.SCHEMA_PATH_XMLDSIG.toString());
XMLInputSource xmlISXMLDSig = new XMLInputSource(null, null, null, isXMLDSig, null);
setEntity("V2G_CI_MsgDef.xsd", xmlISV2GCIMsgDef);
setEntity("V2G_CI_MsgBody.xsd", xmlISV2GCIMsgBody);
setEntity("V2G_CI_MsgHeader.xsd", xmlISV2GCIMsgHeader);
setEntity("V2G_CI_MsgDataTypes.xsd", xmlISV2GCIMsgDataTypes);
setEntity("xmldsig-core-schema.xsd", xmlISXMLDSig);
}
示例2: resolveEntity
import org.apache.xerces.xni.parser.XMLInputSource; //导入依赖的package包/类
@Override
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
//logger.info("Resolving entity for: " + resourceIdentifier.getExpandedSystemId() + " namespace " + resourceIdentifier.getNamespace());
try{
URI originalURI = new URI(resourceIdentifier.getExpandedSystemId());
if(xbrlSchemaRemap.containsKey(originalURI)){
URI newURI = xbrlSchemaRemap.get(originalURI);
return new XMLInputSource(null, newURI.toString(), newURI.toString(), fileCache.getFileInputStream(newURI.toString()), null);
}
}
catch(URISyntaxException e){
}
return new XMLInputSource(resourceIdentifier.getPublicId(),
resourceIdentifier.getExpandedSystemId(),
resourceIdentifier.getExpandedSystemId(),
fileCache.getFileInputStream(resourceIdentifier.getExpandedSystemId()),
null);
}
示例3: preparseGrammar
import org.apache.xerces.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)) {
XMLGrammarLoaderContainer xglc = (XMLGrammarLoaderContainer) fLoaders.get(type);
XMLGrammarLoader gl = xglc.loader;
if (xglc.modCount != fModCount) {
// 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...
}
}
xglc.modCount = fModCount;
}
return gl.loadGrammar(is);
}
return null;
}
示例4: parseDTD
import org.apache.xerces.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;
}
示例5: createXMLInputSource
import org.apache.xerces.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;
}
示例6: saxToXMLInputSource
import org.apache.xerces.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);
}
示例7: validateAnnotations
import org.apache.xerces.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;
}
}
}
示例8: resolveSchema
import org.apache.xerces.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);
}
示例9: resolveSchemaSource
import org.apache.xerces.xni.parser.XMLInputSource; //导入依赖的package包/类
private XMLInputSource resolveSchemaSource(XSDDescription desc, boolean mustResolve,
Element referElement, boolean usePairs) {
XMLInputSource schemaSource = null;
try {
Hashtable 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;
}
示例10: getSchemaDocument1
import org.apache.xerces.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;
}
示例11: openInputSourceStream
import org.apache.xerces.xni.parser.XMLInputSource; //导入依赖的package包/类
/**
* This method tries to open the necessary stream for the given
* XMLInputSource. If the input source already has a character
* stream (java.io.Reader) or a byte stream (java.io.InputStream)
* set, this method returns immediately. However, if no character
* or byte stream is already open, this method attempts to open
* an input stream using the source's system identifier.
*
* @param source The input source to open.
*/
protected void openInputSourceStream(XMLInputSource source)
throws IOException {
if (source.getCharacterStream() != null) {
return;
}
InputStream stream = source.getByteStream();
if (stream == null) {
String systemId = source.getSystemId();
try {
URL url = new URL(systemId);
stream = url.openStream();
}
catch (MalformedURLException e) {
stream = new FileInputStream(systemId);
}
source.setByteStream(stream);
}
}
示例12: resolveEntity
import org.apache.xerces.xni.parser.XMLInputSource; //导入依赖的package包/类
@Override
public XMLInputSource resolveEntity(XMLResourceIdentifier identifier)
throws XNIException, IOException {
String systemId = identifier.getExpandedSystemId();
String redirectedSystemId = systemId != null ? redirect(systemId)
: null;
LOG.debug("'" + systemId + "' -> '" + redirectedSystemId + "'");
if (redirectedSystemId != null
&& redirectedSystemId.startsWith("https:")) {
InputStream is = UrlUtils.open(new URL(redirectedSystemId));
return new XMLInputSource(null, systemId, redirectedSystemId, is,
null);
}
return new XMLInputSource(null, redirectedSystemId, null);
}
示例13: endElement
import org.apache.xerces.xni.parser.XMLInputSource; //导入依赖的package包/类
@Override
public void endElement(QName element, Augmentations augs) throws XNIException {
if (currentOsmlTag != null && "script".equalsIgnoreCase(element.rawname)) {
QName endingTag = currentOsmlTag;
currentOsmlTag = null;
XMLInputSource scriptSource = new XMLInputSource(null, null, null);
scriptSource.setCharacterStream(new StringReader(scriptContent.toString()));
scriptContent.setLength(0);
// Evaluate the content of the script block immediately
scanner.evaluateInputSource(scriptSource);
super.endElement(endingTag, augs);
} else {
super.endElement(element, augs);
}
}
示例14: setEntity
import org.apache.xerces.xni.parser.XMLInputSource; //导入依赖的package包/类
public void setEntity(String literalSystemId, XMLInputSource xmlInput) {
if (xmlInputSourceEntities == null) {
xmlInputSourceEntities = new HashMap<String, XMLInputSource>();
}
xmlInputSourceEntities.put(literalSystemId, xmlInput);
}
示例15: resolveEntity
import org.apache.xerces.xni.parser.XMLInputSource; //导入依赖的package包/类
@Override
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
throws XNIException, IOException {
String literalSystemId = resourceIdentifier.getLiteralSystemId();
if (xmlInputSourceEntities != null && xmlInputSourceEntities.containsKey(literalSystemId)) {
return xmlInputSourceEntities.get(literalSystemId);
}
return null;
}