本文整理汇总了Java中nu.xom.ParsingException类的典型用法代码示例。如果您正苦于以下问题:Java ParsingException类的具体用法?Java ParsingException怎么用?Java ParsingException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParsingException类属于nu.xom包,在下文中一共展示了ParsingException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import nu.xom.ParsingException; //导入依赖的package包/类
@Test
public void update()
throws ValidityException, ParsingException, IOException, MojoExecutionException {
Document pom = new Builder().build(new File(new File("src/it/reflector"), "pom.xml"));
Artifact artifact = new DefaultArtifact(
"net.stickycode",
"sticky-coercion",
"jar",
"",
"[3.1,4)");
new StickyBoundsMojo().updateDependency(pom, artifact, "[3.6,4)");
XPathContext context = new XPathContext("mvn", "http://maven.apache.org/POM/4.0.0");
Nodes versions = pom.query("//mvn:version", context);
assertThat(versions.size()).isEqualTo(3);
Nodes nodes = pom.query("//mvn:version[text()='[3.6,4)']", context);
assertThat(nodes.size()).isEqualTo(1);
Node node = nodes.get(0);
assertThat(node.getValue()).isEqualTo("[3.6,4)");
}
示例2: updateWithClassifier
import nu.xom.ParsingException; //导入依赖的package包/类
@Test
public void updateWithClassifier()
throws ValidityException, ParsingException, IOException, MojoExecutionException {
Document pom = new Builder().build(new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("classifiers.xml"))));
Artifact artifact = new DefaultArtifact(
"net.stickycode",
"sticky-coercion",
"jar",
"",
"[2.1,4)");
new StickyBoundsMojo().updateDependency(pom, artifact, "[2.6,3)");
XPathContext context = new XPathContext("mvn", "http://maven.apache.org/POM/4.0.0");
Nodes versions = pom.query("//mvn:version", context);
assertThat(versions.size()).isEqualTo(4);
Nodes nodes = pom.query("//mvn:version[text()='[2.6,3)']", context);
assertThat(nodes.size()).isEqualTo(1);
Node node = nodes.get(0);
assertThat(node.getValue()).isEqualTo("[2.6,3)");
}
示例3: shouldNotModifyDocumentWhenAllXPathsTraversable
import nu.xom.ParsingException; //导入依赖的package包/类
@Test
public void shouldNotModifyDocumentWhenAllXPathsTraversable()
throws XPathExpressionException, ParsingException, IOException {
Map<String, Object> xmlProperties = fixtureAccessor.getXmlProperties();
String xml = fixtureAccessor.getPutValueXml();
Document oldDocument = stringToXml(xml);
Document builtDocument = new XmlBuilder(namespaceContext)
.putAll(xmlProperties)
.build(oldDocument);
assertThat(xmlToString(builtDocument)).isEqualTo(xml);
builtDocument = new XmlBuilder(namespaceContext)
.putAll(xmlProperties.keySet())
.build(oldDocument);
assertThat(xmlToString(builtDocument)).isEqualTo(xml);
}
示例4: loadXmlDefinition
import nu.xom.ParsingException; //导入依赖的package包/类
/**
* Use the CacheXmlGenerator to create XML from the entity associated with
* the current cache.
*
* @param element Name of the XML element to search for.
* @param attributes
* Attributes of the element that should match, for example "name" or
* "id" and the value they should equal.
*
* @return XML string representation of the entity.
*/
private final String loadXmlDefinition(final String element, final Map<String, String> attributes) {
final Cache cache = CacheFactory.getAnyInstance();
Document document = null;
try {
final StringWriter stringWriter = new StringWriter();
final PrintWriter printWriter = new PrintWriter(stringWriter);
CacheXmlGenerator.generate(cache, printWriter, false, false, false);
printWriter.close();
// Remove the DOCTYPE line when getting the string to prevent
// errors when trying to locate the DTD.
String xml = stringWriter.toString().replaceFirst("<!DOCTYPE.*>", "");
document = new Builder(false).build(xml, null);
} catch (ValidityException vex) {
cache.getLogger().error("Could not parse XML when creating XMLEntity", vex);
} catch (ParsingException pex) {
cache.getLogger().error("Could not parse XML when creating XMLEntity", pex);
} catch (IOException ioex) {
cache.getLogger().error("Could not parse XML when creating XMLEntity", ioex);
}
Nodes nodes = document.query(createQueryString(element, attributes));
if (nodes.size() != 0) {
return nodes.get(0).toXML();
}
cache.getLogger().warning("No XML definition could be found with name=" + element + " and attributes=" + attributes);
return null;
}
示例5: Mei4Gui
import nu.xom.ParsingException; //导入依赖的package包/类
/**
* constructor
* @param file
* @param app
*/
public Mei4Gui(File file, MeicoApp app) throws InvalidFileTypeException, IOException, ParsingException, UnsupportedAudioFileException {
this.msm = new ArrayList<>();
if (file.getName().substring(file.getName().lastIndexOf(".")).toLowerCase().equals(".mei")) { // if it is an mei file
this.readMeiFile(file, false); // load it
}
else { // otherwise try loading it as an msm (or midi) object
this.msm.add(new Msm4Gui(file, app)); // load it into the msms list
}
this.panel = new JPanel(); // initialize the gui component
this.app = app; // store the reference to the meico app
this.idsAdded = false;
this.copyofsResolved = false;
this.expansionsResolved = false;
this.ppq = 720;
}
示例6: createReader
import nu.xom.ParsingException; //导入依赖的package包/类
public HierarchicalStreamReader createReader(File paramFile)
{
try
{
XomReader localXomReader = new XomReader(this.builder.build(paramFile), getNameCoder());
return localXomReader;
}
catch (ValidityException localValidityException)
{
throw new StreamException(localValidityException);
}
catch (ParsingException localParsingException)
{
throw new StreamException(localParsingException);
}
catch (IOException localIOException)
{
throw new StreamException(localIOException);
}
}
示例7: updateTheClassifier
import nu.xom.ParsingException; //导入依赖的package包/类
@Test
public void updateTheClassifier()
throws ValidityException, ParsingException, IOException, MojoExecutionException {
Document pom = new Builder().build(new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("classifiers.xml"))));
Artifact artifact = new DefaultArtifact(
"net.stickycode",
"sticky-coercion",
"jar",
"test-jar",
"[2.1,4)");
new StickyBoundsMojo().updateDependency(pom, artifact, "[2.6,3)");
XPathContext context = new XPathContext("mvn", "http://maven.apache.org/POM/4.0.0");
Nodes versions = pom.query("//mvn:version", context);
assertThat(versions.size()).isEqualTo(4);
Nodes nodes = pom.query("//mvn:version[text()='[2.6,3)']", context);
assertThat(nodes.size()).isEqualTo(1);
Node node = nodes.get(0);
assertThat(node.getValue()).isEqualTo("[2.6,3)");
}
示例8: readBrick
import nu.xom.ParsingException; //导入依赖的package包/类
private static GeometryWithMaterial readBrick(Element partElement, LIFReader dbLifReader, HashMap<Integer, Material> materials) throws IOException, ValidityException, ParsingException {
int partID = Integer.parseInt(partElement.getAttributeValue("designID"));
String materialName = partElement.getAttributeValue("materials");
//no support for multiple materials.
if(materialName.indexOf(',') != -1) {
String[] parts = materialName.split(",");
materialName = parts[0];
}
int materialID = Integer.parseInt(materialName);
Material material = materials.get(materialID);
VBOContents combo = BrickReader.readBrick(dbLifReader, partID);
Elements boneElements = partElement.getChildElements("Bone");
//Single bone element = non-flex brick
if(boneElements.size() == 1) {
String transformationString = boneElements.get(0).getAttributeValue("transformation");
Matrix4f transformation = Bone.readBrickTransformation(transformationString);
combo = combo.transform(transformation);
} else {
combo = FlexElement.transform(combo, boneElements, partID, dbLifReader);
}
return new GeometryWithMaterial(combo, material);
}
示例9: SettingsManager
import nu.xom.ParsingException; //导入依赖的package包/类
/**
* Constructs the class. Requires settings.xml to be present to run
*/
public SettingsManager() {
String currentDir = System.getProperty("user.dir");
String settingDir = currentDir + "/settings/";
File f = new File(settingDir + "settings.xml");
if (f.exists() && !f.isDirectory()) {
try {
Builder parser = new Builder();
Document doc = parser.build(f);
Element root = doc.getRootElement();
Element eUsername = root.getFirstChildElement("Username");
username = eUsername.getValue();
Element ePassword = root.getFirstChildElement("Password");
password = ePassword.getValue();
requiresAuth = true;
} catch (ParsingException|IOException e) {
e.printStackTrace();
}
}
else {
requiresAuth = false;
}
}
示例10: getDocument
import nu.xom.ParsingException; //导入依赖的package包/类
/**
* @param path the path of the requested document
* @return the document that lives under the given path in the ZIP fs.
* @throws IOException in case of any failure
*/
public Document getDocument(String path) throws IOException {
Builder builder = new Builder();
try {
byte[] documentData = content.get(path);
if (documentData == null) {
throw new IOException(
Messages.getString(
"ZipFs.invalidDocument",//$NON-NLS-1$
path));
}
return builder.build(new ByteArrayInputStream(content.get(path)));
} catch (ParsingException e) {
throw new IOException(e);
}
}
示例11: makePublicationStmt
import nu.xom.ParsingException; //导入依赖的package包/类
/**
* Make a <publicationStmt>
* @param document
* @throws IOException
*/
private void makePublicationStmt(Document document) throws IOException {
Element publicationStmtElement = DocumentUtil.getFirstMatch(
document,
"/tei:TEI/tei:teiHeader/tei:fileDesc/tei:publicationStmt", //$NON-NLS-1$
xPathContext);
publicationStmtElement.removeChildren();
try {
Document publicationStmtDoc =
new Builder().build(
PropertyKey.publicationStmt.getValue(), TeiNamespace.TEI.toUri());
publicationStmtElement.getParent().replaceChild(
publicationStmtElement, publicationStmtDoc.getRootElement().copy());
}
catch (ParsingException pe) {
throw new IOException(pe);
}
}
示例12: getInputDataTypes
import nu.xom.ParsingException; //导入依赖的package包/类
/**
* @return available input data types as offered by OxGarage
* @throws IOException in case of any failure
*/
Document getInputDataTypes() throws IOException {
String uri = baseURL + CONVERSION_OPERATION;
ClientResource client = new ClientResource(Context.getCurrent(), Method.GET, uri);
Representation result = client.get();
Builder builder = new Builder();
try {
Document inputDataTypes = builder.build(result.getStream());
return inputDataTypes;
}
catch (ParsingException e) {
throw new IOException(e);
}
}
示例13: main
import nu.xom.ParsingException; //导入依赖的package包/类
public static void main(String[] args) throws IOException, ParsingException
{
if (args.length <= 2) {
System.out.println("Usage: <pages.xml file> <givennames out> <surnames out>");
}
else {
RelatedNamesExtractor extractor = new RelatedNamesExtractor(args[1], args[2]);
WikiReader wikiReader = new WikiReader();
wikiReader.setSkipRedirects(true);
wikiReader.addWikiPageParser(extractor);
InputStream in = new FileInputStream(args[0]);
wikiReader.read(in);
in.close();
extractor.close();
}
}
示例14: parse
import nu.xom.ParsingException; //导入依赖的package包/类
public void parse(String title, String text, int pageId, int latestRevId, String username, String timestamp, String comment) throws IOException, ParsingException {
if(title.startsWith(currentPagePrefix)) {
String[] split = splitStructuredWikiText(currentPagePrefix.toLowerCase().substring(0,currentPagePrefix.indexOf(':')), text);
title = title.substring(currentPagePrefix.length());
String structuredData = split[0];
String wikiText = split[1];
if (!Util.isEmpty(structuredData)) {
Document doc = parseText(split[0]);
Element elm = doc.getRootElement();
Elements prevParents = elm.getChildElements("related");
for (int i = 0; i < prevParents.size(); i++) {
Element prevParent = prevParents.get(i);
String name = Util.translateHtmlCharacterEntities(prevParent.getAttributeValue("name"));
if(name != null){//shouldn't happen unless some incorrect xml
String key = clean(name);
if(names_Links.containsKey(key)){
Set<String> temp = names_Links.get(key);
temp.add(title);
}
}
}
}
names_Links.remove(clean(title));
}
}
示例15: main
import nu.xom.ParsingException; //导入依赖的package包/类
public static void main(String[] args) throws IOException, ParsingException
{
if (args.length <= 3) {
System.out.println("Usage: <pages.xml file> <Prefix to do> <output NameFile> <Common Names>");
}
else {
CommonNamePagesToCreate surnames = new CommonNamePagesToCreate();
surnames.setPrefix(args[1]);
surnames.loadCommonNames(args[3]);
WikiReader wikiReader = new WikiReader();
wikiReader.setSkipRedirects(true);
wikiReader.addWikiPageParser(surnames);
InputStream in = new FileInputStream(args[0]);
wikiReader.read(in);
in.close();
surnames.openFile(args[2]);
surnames.writeFile();
surnames.close();
}
}