本文整理匯總了Java中javax.xml.parsers.SAXParserFactory.setXIncludeAware方法的典型用法代碼示例。如果您正苦於以下問題:Java SAXParserFactory.setXIncludeAware方法的具體用法?Java SAXParserFactory.setXIncludeAware怎麽用?Java SAXParserFactory.setXIncludeAware使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.parsers.SAXParserFactory
的用法示例。
在下文中一共展示了SAXParserFactory.setXIncludeAware方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testXIncludeSAXPos
import javax.xml.parsers.SAXParserFactory; //導入方法依賴的package包/類
/**
* Test xi:include with a SAXParserFactory.
*
* @throws Exception If any errors occur.
*/
@Test(groups = {"readWriteLocalFiles"})
public void testXIncludeSAXPos() throws Exception {
String resultFile = USER_DIR + "doc_xinclude.out";
String goldFile = GOLDEN_DIR + "doc_xincludeGold.xml";
String xmlFile = XML_DIR + "doc_xinclude.xml";
try(FileOutputStream fos = new FileOutputStream(resultFile)) {
XInclHandler xh = new XInclHandler(fos, null);
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setXIncludeAware(true);
spf.setFeature(FEATURE_NAME, true);
spf.newSAXParser().parse(new File(xmlFile), xh);
}
assertTrue(compareDocumentWithGold(goldFile, resultFile));
}
示例2: testXPointerPos
import javax.xml.parsers.SAXParserFactory; //導入方法依賴的package包/類
/**
* Test the XPointer framework with a SAX object.
*
* @throws Exception If any errors occur.
*/
@Test(groups = {"readWriteLocalFiles"})
public void testXPointerPos() throws Exception {
String resultFile = USER_DIR + "doc_xpointer.out";
String goldFile = GOLDEN_DIR + "doc_xpointerGold.xml";
String xmlFile = XML_DIR + "doc_xpointer.xml";
try (FileOutputStream fos = new FileOutputStream(resultFile)) {
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setXIncludeAware(true);
spf.setFeature(FEATURE_NAME, true);
// parse the file
spf.newSAXParser().parse(new File(xmlFile), new XInclHandler(fos, null));
}
assertTrue(compareDocumentWithGold(goldFile, resultFile));
}
示例3: setFeature
import javax.xml.parsers.SAXParserFactory; //導入方法依賴的package包/類
private void setFeature(SAXParserFactory factory, String feature, boolean enable)
{
try
{
if (ADDITIONAL_FEATURE_X_INCLUDE_AWARE.equals(feature))
{
factory.setXIncludeAware(enable);
}
else if (!ADDITIONAL_FEATURE_EXPAND_ENTITY_REFERENCES.equals(feature)) // Does not exist on SAXParserFactory
{
factory.setFeature(feature, enable);
}
debug(debugCounter+" SAXParserFactory "+feature+" "+enable);
}
catch (ParserConfigurationException | SAXNotSupportedException | SAXNotRecognizedException e)
{
logConfigurationFailure(factory.getClass().getName(), feature, e);
}
}
示例4: getSAXParser
import javax.xml.parsers.SAXParserFactory; //導入方法依賴的package包/類
/**
* Returns an instance of SAXParser with a catalog if one is provided.
*
* @param setUseCatalog a flag indicates whether USE_CATALOG shall be set
* through the factory
* @param useCatalog the value of USE_CATALOG
* @param catalog a catalog
* @return an instance of SAXParser
* @throws ParserConfigurationException
* @throws SAXException
*/
SAXParser getSAXParser(boolean setUseCatalog, boolean useCatalog, String catalog)
throws ParserConfigurationException, SAXException {
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setXIncludeAware(true);
if (setUseCatalog) {
spf.setFeature(XMLConstants.USE_CATALOG, useCatalog);
}
SAXParser parser = spf.newSAXParser();
parser.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog);
return parser;
}