本文整理汇总了Java中org.w3c.dom.ls.LSParser.parseURI方法的典型用法代码示例。如果您正苦于以下问题:Java LSParser.parseURI方法的具体用法?Java LSParser.parseURI怎么用?Java LSParser.parseURI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.ls.LSParser
的用法示例。
在下文中一共展示了LSParser.parseURI方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBeanDefinition
import org.w3c.dom.ls.LSParser; //导入方法依赖的package包/类
/**
* Finds bean definition element by id and type in Spring application context and
* performs unmarshalling in order to return JaxB object.
* @param project
* @param id
* @param type
* @return
*/
public <T> T getBeanDefinition(File configFile, Project project, String id, Class<T> type) {
LSParser parser = XMLUtils.createLSParser();
GetSpringBeanFilter filter = new GetSpringBeanFilter(id, type);
parser.setFilter(filter);
List<File> configFiles = new ArrayList<>();
configFiles.add(configFile);
configFiles.addAll(getConfigImports(configFile, project));
for (File file : configFiles) {
parser.parseURI(file.toURI().toString());
if (filter.getBeanDefinition() != null) {
return createJaxbObjectFromElement(filter.getBeanDefinition());
}
}
return null;
}
示例2: getBeanDefinitions
import org.w3c.dom.ls.LSParser; //导入方法依赖的package包/类
/**
* Finds all bean definition elements by type and attribute values in Spring application context and
* performs unmarshalling in order to return a list of JaxB object.
* @param project
* @param type
* @param attributes
* @return
*/
public <T> List<T> getBeanDefinitions(File configFile, Project project, Class<T> type, Map<String, String> attributes) {
List<T> beanDefinitions = new ArrayList<T>();
List<File> importedFiles = getConfigImports(configFile, project);
for (File importLocation : importedFiles) {
beanDefinitions.addAll(getBeanDefinitions(importLocation, project, type, attributes));
}
LSParser parser = XMLUtils.createLSParser();
GetSpringBeansFilter filter = new GetSpringBeansFilter(type, attributes);
parser.setFilter(filter);
parser.parseURI(configFile.toURI().toString());
for (Element element : filter.getBeanDefinitions()) {
beanDefinitions.add(createJaxbObjectFromElement(element));
}
return beanDefinitions;
}
示例3: testCheckScreenNameExists
import org.w3c.dom.ls.LSParser; //导入方法依赖的package包/类
/**
* Checking for namespace normalization.
* @see <a href="content/screenName.xml">screenName.xml</a> has prefix of
* userName is bound to "http://hibid.com/user" namespace normalization
* will create a namespace of prefix us and attach userEmail.
*
* @throws Exception If any errors occur.
*/
@Test
public void testCheckScreenNameExists() throws Exception {
String resultFile = USER_DIR + "screenName.out";
String xmlFile = XML_DIR + "screenName.xml";
String goldFile = GOLDEN_DIR + "screenNameGold.xml";
String nsTagName = "http://hibid.com/screenName";
String userNs = "http://hibid.com/user";
try (FileOutputStream output = new FileOutputStream(resultFile)) {
DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
LSSerializer writer = impl.createLSSerializer();
LSParser builder = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
Document document = builder.parseURI(xmlFile);
NodeList nl = document.getElementsByTagNameNS(nsTagName, "screen-name");
assertEquals(nl.getLength(), 1);
Element screenName = (Element)nl.item(0);
Element userEmail = document.createElementNS(userNs, "userEmail");
assertTrue(userEmail.isDefaultNamespace(userNs));
Text email = document.createTextNode("[email protected]");
userEmail.appendChild(email);
screenName.appendChild(userEmail);
document.normalizeDocument();
MyDOMOutput domoutput = new MyDOMOutput();
domoutput.setByteStream(output);
writer.write(document, domoutput);
}
assertTrue(compareDocumentWithGold(goldFile, resultFile));
}
示例4: getConfigImports
import org.w3c.dom.ls.LSParser; //导入方法依赖的package包/类
/**
* Reads file import locations from Spring bean application context.
* @param project
* @return
*/
public List<File> getConfigImports(File configFile, Project project) {
LSParser parser = XMLUtils.createLSParser();
GetSpringImportsFilter filter = new GetSpringImportsFilter(configFile);
parser.setFilter(filter);
parser.parseURI(configFile.toURI().toString());
return filter.getImportedFiles();
}