本文整理汇总了Java中org.xml.sax.InputSource.setSystemId方法的典型用法代码示例。如果您正苦于以下问题:Java InputSource.setSystemId方法的具体用法?Java InputSource.setSystemId怎么用?Java InputSource.setSystemId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xml.sax.InputSource
的用法示例。
在下文中一共展示了InputSource.setSystemId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveEntity
import org.xml.sax.InputSource; //导入方法依赖的package包/类
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
log("publicId: " + publicId + " systemId: " + systemId, Project.MSG_VERBOSE);
int idx = systemId.lastIndexOf('/');
String last = systemId.substring(idx + 1);
if (localDTDs.contains(last)) {
log("Resolved to embedded DTD");
InputSource is = new InputSource(Arch.class.getResourceAsStream(last));
is.setSystemId(systemId);
return is;
} else {
log("Not resolved");
return null;
}
}
示例2: parse
import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
* Parse a DTD.
*/
public void parse(String uri)
throws IOException, SAXException {
InputSource inSource;
init();
// System.out.println ("parse (\"" + uri + "\")");
inSource = resolver.resolveEntity(null, uri);
// If custom resolver punts resolution to parser, handle it ...
if (inSource == null) {
inSource = Resolver.createInputSource(new java.net.URL(uri), false);
// ... or if custom resolver doesn't correctly construct the
// input entity, patch it up enough so relative URIs work, and
// issue a warning to minimize later confusion.
} else if (inSource.getSystemId() == null) {
warning("P-065", null);
inSource.setSystemId(uri);
}
parseInternal(inSource);
}
示例3: getRoot
import org.xml.sax.InputSource; //导入方法依赖的package包/类
private Element getRoot(String schemaText, String docText) throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
InputSource inSchema = new InputSource(new StringReader(schemaText));
inSchema.setSystemId("schema.xsd");
dbf.setNamespaceAware(true);
dbf.setValidating(true);
dbf.setAttribute(SCHEMA_LANGUAGE, W3C_XML_SCHEMA_NS_URI);
dbf.setAttribute(SCHEMA_SOURCE, inSchema);
DocumentBuilder parser = dbf.newDocumentBuilder();
InputSource inSource = new InputSource(new StringReader(docText));
inSource.setSystemId("doc.xml");
Document document = parser.parse(inSource);
return document.getDocumentElement();
}
示例4: processStreamAndScheduleJobs
import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
* Process the xmlfile named <code>fileName</code> with the given system
* ID.
*
* @param stream
* an input stream containing the xml content.
* @param systemId
* system ID.
*/
public void processStreamAndScheduleJobs(InputStream stream, String systemId, Scheduler sched)
throws ValidationException, ParserConfigurationException,
SAXException, XPathException, IOException, SchedulerException,
ClassNotFoundException, ParseException {
prepForProcessing();
log.info("Parsing XML from stream with systemId: " + systemId);
InputSource is = new InputSource(stream);
is.setSystemId(systemId);
process(is);
executePreProcessCommands(sched);
scheduleJobs(sched);
maybeThrowValidationException();
}
示例5: parse
import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
* Parse a DTD.
*/
public void parse(String uri)
throws IOException, SAXException {
InputSource in;
init();
// System.out.println ("parse (\"" + uri + "\")");
in = resolver.resolveEntity(null, uri);
// If custom resolver punts resolution to parser, handle it ...
if (in == null) {
in = Resolver.createInputSource(new java.net.URL(uri), false);
// ... or if custom resolver doesn't correctly construct the
// input entity, patch it up enough so relative URIs work, and
// issue a warning to minimize later confusion.
} else if (in.getSystemId() == null) {
warning("P-065", null);
in.setSystemId(uri);
}
parseInternal(in);
}
示例6: inform
import org.xml.sax.InputSource; //导入方法依赖的package包/类
@Override
public void inform(ResourceLoader loader) throws IOException {
InputStream stream = null;
try {
if (dictFile != null) // the dictionary can be empty.
dictionary = getWordSet(loader, dictFile, false);
// TODO: Broken, because we cannot resolve real system id
// ResourceLoader should also supply method like ClassLoader to get resource URL
stream = loader.openResource(hypFile);
final InputSource is = new InputSource(stream);
is.setEncoding(encoding); // if it's null let xml parser decide
is.setSystemId(hypFile);
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_4_0)) {
hyphenator = HyphenationCompoundWordTokenFilter.getHyphenationTree(is);
} else {
hyphenator = Lucene43HyphenationCompoundWordTokenFilter.getHyphenationTree(is);
}
} finally {
IOUtils.closeWhileHandlingException(stream);
}
}
示例7: parse
import org.xml.sax.InputSource; //导入方法依赖的package包/类
void parse() throws SAXException {
String xml = "<data>\n<broken/>\u0000</data>";
try {
InputSource is = new InputSource(new StringReader(xml));
is.setSystemId("file:///path/to/some.xml");
// notice that exception thrown here doesn't include the line number
// information when reported by JVM -- CR6889654
SAXParserFactory.newInstance().newSAXParser().parse(is, new DefaultHandler());
} catch (SAXException e) {
// notice that this message isn't getting displayed -- CR6889649
throw new SAXException(MSG, e);
} catch (ParserConfigurationException pce) {
} catch (IOException ioe) {
}
}
示例8: resolveEntity
import org.xml.sax.InputSource; //导入方法依赖的package包/类
@Override
public InputSource resolveEntity(final String publicId, final String systemId) throws SAXException {
if (ConfigurationConstants.CONFIG_SCHEMA.equals(systemId)) {
InputStream stream = ConfigurationManager.class.getResourceAsStream(ConfigurationConstants.CONFIG_SCHEMA_LOCATION);
if (stream != null) {
InputSource source = new InputSource(stream);
source.setPublicId(publicId);
source.setSystemId(systemId);
return source;
} else {
throw new SAXException("Cannot find schema " + ConfigurationConstants.CONFIG_SCHEMA);
}
}
return super.resolveEntity(publicId, systemId);
}
示例9: compile
import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
* Compiles an XSL stylesheet pointed to by a URL
* @param url An URL containing the input XSL stylesheet
* @param name The name to assign to the translet class
*/
public boolean compile(URL url, String name) {
try {
// Open input stream from URL and wrap inside InputSource
final InputStream stream = url.openStream();
final InputSource input = new InputSource(stream);
input.setSystemId(url.toString());
return compile(input, name);
}
catch (IOException e) {
_parser.reportError(Constants.FATAL, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
return false;
}
}
示例10: resolveEntity
import org.xml.sax.InputSource; //导入方法依赖的package包/类
/** Tries to find the entity on system file system.
*/
public InputSource resolveEntity(String publicID, String systemID) throws IOException, SAXException {
if (publicID == null) {
return null;
}
String id = convertPublicId (publicID);
StringBuffer sb = new StringBuffer (200);
sb.append (ENTITY_PREFIX);
sb.append (id);
FileObject fo = FileUtil.getConfigFile (sb.toString ());
if (fo != null) {
// fill in InputSource instance
InputSource in = new InputSource (fo.getInputStream ());
try {
Object myPublicID = fo.getAttribute("hint.originalPublicID"); //NOI18N
if (myPublicID instanceof String) {
in.setPublicId((String)myPublicID);
}
URL url = fo.getURL();
in.setSystemId(url.toString()); // we get nasty nbfs: instead nbres: but it is enough
} catch (IOException ex) {
// do no care just no system id
}
return in;
} else {
return null;
}
}
示例11: resolveEntity
import org.xml.sax.InputSource; //导入方法依赖的package包/类
public InputSource resolveEntity(String publicid, String sysId) {
if (sysId.equals("http://astro.com/stylesheets/toptemplate")) {
InputSource retval = new InputSource(TOPTEMPLXSL);
retval.setSystemId(filenameToURL(TOPTEMPLXSL));
return retval;
} else {
return null; // use default behavior
}
}
示例12: streamSourceToInputSource
import org.xml.sax.InputSource; //导入方法依赖的package包/类
private static InputSource streamSourceToInputSource( StreamSource ss ) {
InputSource is = new InputSource();
is.setSystemId( ss.getSystemId() );
is.setByteStream( ss.getInputStream() );
is.setCharacterStream( ss.getReader() );
return is;
}
示例13: resolveEntity
import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
* Resolves the given resource and adapts the <code>LSInput</code>
* returned into an <code>InputSource</code>.
*/
public InputSource resolveEntity(String name, String publicId,
String baseURI, String systemId) throws SAXException, IOException {
if (fEntityResolver != null) {
LSInput lsInput = fEntityResolver.resolveResource(XML_TYPE, null, publicId, systemId, baseURI);
if (lsInput != null) {
final String pubId = lsInput.getPublicId();
final String sysId = lsInput.getSystemId();
final String baseSystemId = lsInput.getBaseURI();
final Reader charStream = lsInput.getCharacterStream();
final InputStream byteStream = lsInput.getByteStream();
final String data = lsInput.getStringData();
final String encoding = lsInput.getEncoding();
/**
* An LSParser looks at inputs specified in LSInput in
* the following order: characterStream, byteStream,
* stringData, systemId, publicId. For consistency
* with the DOM Level 3 Load and Save Recommendation
* use the same lookup order here.
*/
InputSource inputSource = new InputSource();
inputSource.setPublicId(pubId);
inputSource.setSystemId((baseSystemId != null) ? resolveSystemId(sysId, baseSystemId) : sysId);
if (charStream != null) {
inputSource.setCharacterStream(charStream);
}
else if (byteStream != null) {
inputSource.setByteStream(byteStream);
}
else if (data != null && data.length() != 0) {
inputSource.setCharacterStream(new StringReader(data));
}
inputSource.setEncoding(encoding);
return inputSource;
}
}
return null;
}
示例14: parse
import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
* Parse the content of the specified file using this Digester. Returns
* the root element from the object stack (if any).
*
* @param file File containing the XML data to be parsed
*
* @exception IOException if an input/output error occurs
* @exception SAXException if a parsing exception occurs
*/
public Object parse(File file) throws IOException, SAXException {
configure();
InputSource input = new InputSource(new FileInputStream(file));
input.setSystemId("file://" + file.getAbsolutePath());
getXMLReader().parse(input);
return (root);
}
示例15: resolver06
import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
* This is to test the URIResolver.resolve() method when a transformer is
* created using SAXSource. style-sheet file has xsl:import in it.
*
* @throws Exception If any errors occur.
*/
@Test
public static void resolver06() throws Exception {
try (FileInputStream fis = new FileInputStream(XSL_IMPORT_FILE)){
URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
TransformerFactory tfactory = TransformerFactory.newInstance();
tfactory.setURIResolver(resolver);
InputSource is = new InputSource(fis);
is.setSystemId(SYSTEM_ID);
SAXSource saxSource = new SAXSource(is);
assertNotNull(tfactory.newTransformer(saxSource));
}
}