当前位置: 首页>>代码示例>>Java>>正文


Java InputSource.setSystemId方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:Arch.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:DTDParser.java

示例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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:TypeInfoTest.java

示例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();
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:28,代码来源:XMLSchedulingDataProcessor.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:DTDParser.java

示例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);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:HyphenationCompoundWordTokenFilterFactory.java

示例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) {

    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:Bug6889654Test.java

示例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);
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:18,代码来源:DefaultConfigurationManager.java

示例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;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:XSLTC.java

示例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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:FileEntityResolver.java

示例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
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:SAXFilterFactoryImpl.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:AbstractUnmarshallerImpl.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:44,代码来源:ValidatorHandlerImpl.java

示例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);

}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:19,代码来源:Digester.java

示例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));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:URIResolverTest.java


注:本文中的org.xml.sax.InputSource.setSystemId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。