nu.xom.ParsingException Java Examples
The following examples show how to use
nu.xom.ParsingException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLUtil.java From rest-client with Apache License 2.0 | 8 votes |
@Deprecated public static String indentXML(final String in) throws XMLException, IOException { try { Builder parser = new Builder(); Document doc = parser.build(in, null); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Serializer serializer = new Serializer(baos); serializer.setIndent(4); serializer.setMaxLength(69); serializer.write(doc); return new String(baos.toByteArray()); } catch (ParsingException ex) { // LOG.log(Level.SEVERE, null, ex); throw new XMLException("XML indentation failed.", ex); } }
Example #2
Source File: FreemarkerTest.java From cloud-opensource-java with Apache License 2.0 | 6 votes |
@Test public void testVersionIndex() throws IOException, TemplateException, URISyntaxException, ParsingException { Path output = DashboardMain.generateVersionIndex( "com.google.cloud", "libraries-bom", ImmutableList.of("1.0.0", "2.0.0", "2.1.0-SNAPSHOT")); Assert.assertTrue( output.endsWith(Paths.get("target", "com.google.cloud", "libraries-bom", "index.html"))); Assert.assertTrue(Files.isRegularFile(output)); Document document = builder.build(output.toFile()); Nodes links = document.query("//a/@href"); Assert.assertEquals(3, links.size()); Node snapshotLink = links.get(2); // 2.1.0-SNAPSHOT has directory 'snapshot' Assert.assertEquals("snapshot/index.html", snapshotLink.getValue()); }
Example #3
Source File: SettingsManager.java From ciscorouter with MIT License | 6 votes |
/** * 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; } }
Example #4
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 6 votes |
@Test public void testComponent_linkageCheckResult() throws IOException, ParsingException { Document document = parseOutputFile( "com.google.http-client_google-http-client-appengine_1.29.1.html"); Nodes reports = document.query("//p[@class='jar-linkage-report']"); Assert.assertEquals(1, reports.size()); Truth.assertThat(trimAndCollapseWhiteSpace(reports.get(0).getValue())) .isEqualTo("91 target classes causing linkage errors referenced from 501 source classes."); Nodes causes = document.query("//p[@class='jar-linkage-report-cause']"); Truth.assertWithMessage( "google-http-client-appengine should show linkage errors for RpcStubDescriptor") .that(causes) .comparingElementsUsing(NODE_VALUES) .contains( "Class com.google.net.rpc3.client.RpcStubDescriptor is not found," + " referenced from 21 classes ▶"); // '▶' is the toggle button }
Example #5
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 6 votes |
@Test public void testComponent_failure() throws IOException, ParsingException { Document document = parseOutputFile( "com.google.api.grpc_grpc-google-common-protos_1.14.0.html"); // com.google.api.grpc:grpc-google-common-protos:1.14.0 has no green section Nodes greens = document.query("//h3[@style='color: green']"); Assert.assertEquals(0, greens.size()); // "Global Upper Bounds Fixes", "Upper Bounds Fixes", and "Suggested Dependency Updates" are red Nodes reds = document.query("//h3[@style='color: red']"); Assert.assertEquals(3, reds.size()); Nodes presDependencyMediation = document.query("//pre[@class='suggested-dependency-mediation']"); Assert.assertTrue( "For failed component, suggested dependency should be shown", presDependencyMediation.size() >= 1); Nodes dependencyTree = document.query("//p[@class='dependency-tree-node']"); Assert.assertTrue( "Dependency Tree should be shown in dashboard even when FAILED", dependencyTree.size() > 0); }
Example #6
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 6 votes |
@Test public void testGlobalUpperBoundUpgradeMessage() throws IOException, ParsingException { // Case 1: BOM needs to be updated Document document = parseOutputFile("com.google.protobuf_protobuf-java-util_3.6.1.html"); Nodes globalUpperBoundBomUpgradeNodes = document.query("//li[@class='global-upper-bound-bom-upgrade']"); Truth.assertThat(globalUpperBoundBomUpgradeNodes.size()).isEqualTo(1); String bomUpgradeMessage = globalUpperBoundBomUpgradeNodes.get(0).getValue(); Truth.assertThat(bomUpgradeMessage).contains( "Upgrade com.google.protobuf:protobuf-java-util:jar:3.6.1 in the BOM to version \"3.7.1\""); // Case 2: Dependency needs to be updated Nodes globalUpperBoundDependencyUpgradeNodes = document.query("//li[@class='global-upper-bound-dependency-upgrade']"); // The artifact report should contain the following 6 global upper bound dependency upgrades: // Upgrade com.google.guava:guava:jar:19.0 to version "27.1-android" // Upgrade com.google.protobuf:protobuf-java:jar:3.6.1 to version "3.7.1" Truth.assertThat(globalUpperBoundDependencyUpgradeNodes.size()).isEqualTo(2); String dependencyUpgradeMessage = globalUpperBoundDependencyUpgradeNodes.get(0).getValue(); Truth.assertThat(dependencyUpgradeMessage).contains( "Upgrade com.google.guava:guava:jar:19.0 to version \"27.1-android\""); }
Example #7
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testDependencyTrees() throws IOException, ParsingException { Document document = parseOutputFile("dependency_trees.html"); Nodes dependencyTreeParagraph = document.query("//p[@class='dependency-tree-node']"); Assert.assertEquals(53144, dependencyTreeParagraph.size()); Assert.assertEquals( "com.google.protobuf:protobuf-java:jar:3.6.1", dependencyTreeParagraph.get(0).getValue()); }
Example #8
Source File: ResponseCommand.java From timbuctoo with GNU General Public License v3.0 | 5 votes |
@Override public void verify(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder) { ValidationResult validationResult; if (!StringUtils.isBlank(verificationMethod)) { evaluator.setVariable("#nl_knaw_huygens_httpcommand_result", requestCommand.getActualResult()); evaluator.setVariable("#nl_knaw_huygens_httpcommand_expectation", expectation); validationResult = (ValidationResult) evaluator.evaluate( verificationMethod + "(#nl_knaw_huygens_httpcommand_expectation, #nl_knaw_huygens_httpcommand_result)" ); evaluator.setVariable("#nl_knaw_huygens_httpcommand_result", null); evaluator.setVariable("#nl_knaw_huygens_httpcommand_expectation", null); } else { validationResult = defaultValidator.validate(expectation, requestCommand.getActualResult()); } Element caption = null; if (addCaptions) { caption = new Element("div").addAttribute("class", "responseCaption").appendText("Response:"); } Element resultElement = replaceWithEmptyElement(commandCall.getElement(), name, namespace, caption); addClass(resultElement, "responseContent"); try { Builder builder = new Builder(); Document document = builder.build(new StringReader(validationResult.getMessage())); //new Element() creates a deepcopy not attached to the doc nu.xom.Element rootElement = new nu.xom.Element(document.getRootElement()); resultElement.appendChild(new Element(rootElement)); resultRecorder.record(validationResult.isSucceeded() ? Result.SUCCESS : Result.FAILURE); } catch (ParsingException | IOException e) { resultRecorder.record(Result.FAILURE); if (e instanceof ParsingException) { resultElement.appendText( "Error at line " + ((ParsingException) e).getLineNumber() + ", column: " + ((ParsingException) e).getColumnNumber()); resultElement.appendText(validationResult.getMessage()); } } }
Example #9
Source File: XmlPersistenceRead.java From rest-client with Apache License 2.0 | 5 votes |
protected Document getDocumentFromFile(final File f) throws IOException, XMLException { try { Builder parser = new Builder(); Document doc = parser.build(f); return doc; } catch (ParsingException | IOException ex) { throw new XMLException(ex.getMessage(), ex); } }
Example #10
Source File: XmlEntity.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * 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; }
Example #11
Source File: XmlEntity.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * 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; }
Example #12
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testBomCoordinatesInUnstableArtifacts() throws IOException, ParsingException { Document document = parseOutputFile("unstable_artifacts.html"); Nodes bomCoordinatesNodes = document.query("//p[@class='bom-coordinates']"); Assert.assertEquals(1, bomCoordinatesNodes.size()); Assert.assertEquals( "BOM: com.google.cloud:libraries-bom:1.0.0", bomCoordinatesNodes.get(0).getValue()); }
Example #13
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testBomCoordinatesInArtifactDetails() throws IOException, ParsingException { Document document = parseOutputFile("artifact_details.html"); Nodes bomCoordinatesNodes = document.query("//p[@class='bom-coordinates']"); Assert.assertEquals(1, bomCoordinatesNodes.size()); Assert.assertEquals( "BOM: com.google.cloud:libraries-bom:1.0.0", bomCoordinatesNodes.get(0).getValue()); }
Example #14
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testZeroLinkageErrorShowsZero() throws IOException, ParsingException { // grpc-auth does not have a linkage error, and it should show zero in the section Document document = parseOutputFile("io.grpc_grpc-auth_1.20.0.html"); Nodes linkageErrorsTotal = document.query("//p[@id='linkage-errors-total']"); Truth.assertThat(linkageErrorsTotal.size()).isEqualTo(1); Truth.assertThat(linkageErrorsTotal.get(0).getValue()) .contains("0 linkage error(s)"); }
Example #15
Source File: FreemarkerTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testCountFailures() throws IOException, TemplateException, ParsingException { Configuration configuration = DashboardMain.configureFreemarker(); Artifact artifact1 = new DefaultArtifact("io.grpc:grpc-context:1.15.0"); ArtifactResults results1 = new ArtifactResults(artifact1); results1.addResult("Linkage Errors", 56); Artifact artifact2 = new DefaultArtifact("grpc:grpc:1.15.0"); ArtifactResults results2 = new ArtifactResults(artifact2); results2.addResult("Linkage Errors", 0); List<ArtifactResults> table = ImmutableList.of(results1, results2); List<DependencyGraph> globalDependencies = ImmutableList.of(); DashboardMain.generateDashboard( configuration, outputDirectory, table, globalDependencies, symbolProblemTable, new ClassPathResult(LinkedListMultimap.create(), ImmutableList.of()), new Bom("mock:artifact:1.6.7", null)); Path dashboardHtml = outputDirectory.resolve("index.html"); Assert.assertTrue(Files.isRegularFile(dashboardHtml)); Document document = builder.build(dashboardHtml.toFile()); // xom's query cannot specify partial class field, e.g., 'statistic-item' Nodes counts = document.query("//div[@class='container']/div/h2"); Assert.assertTrue(counts.size() > 0); for (int i = 0; i < counts.size(); i++) { Integer.parseInt(counts.get(i).getValue().trim()); } // Linkage Errors Truth.assertThat(counts.get(1).getValue().trim()).isEqualTo("1"); }
Example #16
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUp() throws IOException, ParsingException { // Creates "index.html" and artifact reports in outputDirectory try { outputDirectory = DashboardMain.generate("com.google.cloud:libraries-bom:1.0.0"); } catch (Throwable t) { t.printStackTrace(); Assert.fail("Could not generate dashboard"); } dashboard = parseOutputFile("index.html"); details = parseOutputFile("artifact_details.html"); unstable = parseOutputFile("unstable_artifacts.html"); }
Example #17
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
private static Document parseOutputFile(String fileName) throws IOException, ParsingException { Path html = outputDirectory.resolve(fileName); Assert.assertTrue("Could not find a regular file for " + fileName, Files.isRegularFile(html)); Assert.assertTrue("The file is not readable: " + fileName, Files.isReadable(html)); try (InputStream source = Files.newInputStream(html)) { return builder.build(source); } }
Example #18
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testArtifactDetails() throws IOException, ArtifactDescriptorException { List<Artifact> artifacts = Bom.readBom("com.google.cloud:libraries-bom:1.0.0") .getManagedDependencies(); Assert.assertTrue("Not enough artifacts found", artifacts.size() > 1); Assert.assertEquals("en-US", dashboard.getRootElement().getAttribute("lang").getValue()); Nodes tr = details.query("//tr"); Assert.assertEquals(artifacts.size() + 1, tr.size()); // header row adds 1 for (int i = 1; i < tr.size(); i++) { // start at 1 to skip header row Nodes td = tr.get(i).query("td"); Assert.assertEquals(Artifacts.toCoordinates(artifacts.get(i - 1)), td.get(0).getValue()); for (int j = 1; j < 5; ++j) { // start at 1 to skip the leftmost artifact coordinates column assertValidCellValue((Element) td.get(j)); } } Nodes href = details.query("//tr/td[@class='artifact-name']/a/@href"); for (int i = 0; i < href.size(); i++) { String fileName = href.get(i).getValue(); Artifact artifact = artifacts.get(i); Assert.assertEquals( Artifacts.toCoordinates(artifact).replace(':', '_') + ".html", URLDecoder.decode(fileName, "UTF-8")); Path componentReport = outputDirectory.resolve(fileName); Assert.assertTrue(fileName + " is missing", Files.isRegularFile(componentReport)); try { Document report = builder.build(componentReport.toFile()); Assert.assertEquals("en-US", report.getRootElement().getAttribute("lang").getValue()); } catch (ParsingException ex) { byte[] data = Files.readAllBytes(componentReport); String message = "Could not parse " + componentReport + " at line " + ex.getLineNumber() + ", column " + ex.getColumnNumber() + "\r\n"; message += ex.getMessage() + "\r\n"; message += new String(data, StandardCharsets.UTF_8); Assert.fail(message); } } }
Example #19
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testComponent_success() throws IOException, ParsingException { Document document = parseOutputFile( "com.google.api.grpc_proto-google-common-protos_1.14.0.html"); Nodes greens = document.query("//h3[@style='color: green']"); Assert.assertTrue(greens.size() >= 2); Nodes presDependencyMediation = document.query("//pre[@class='suggested-dependency-mediation']"); // There's a pre tag for dependency Assert.assertEquals(1, presDependencyMediation.size()); Nodes presDependencyTree = document.query("//p[@class='dependency-tree-node']"); Assert.assertTrue( "Dependency Tree should be shown in dashboard", presDependencyTree.size() > 0); }
Example #20
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testLinkageErrorsInProvidedDependency() throws IOException, ParsingException { // google-http-client-appengine has provided dependency to (problematic) appengine-api-1.0-sdk Document document = parseOutputFile( "com.google.http-client_google-http-client-appengine_1.29.1.html"); Nodes linkageCheckMessages = document.query("//ul[@class='jar-linkage-report-cause']/li"); Truth.assertThat(linkageCheckMessages.size()).isGreaterThan(0); Truth.assertThat(linkageCheckMessages.get(0).getValue()) .contains("com.google.appengine.api.appidentity.AppIdentityServicePb"); }
Example #21
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testLinkageErrors_ensureNoDuplicateSymbols() throws IOException, ParsingException { Document document = parseOutputFile("com.google.http-client_google-http-client-appengine_1.29.1.html"); Nodes linkageCheckMessages = document.query("//p[@class='jar-linkage-report-cause']"); Truth.assertThat(linkageCheckMessages.size()).isGreaterThan(0); List<String> messages = new ArrayList<>(); for (int i = 0; i < linkageCheckMessages.size(); ++i) { messages.add(linkageCheckMessages.get(i).getValue()); } // When uniqueness of SymbolProblem and Symbol classes are incorrect, dashboard has duplicates. Truth.assertThat(messages).containsNoDuplicates(); }
Example #22
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testBomCoordinatesInComponent() throws IOException, ParsingException { Document document = parseOutputFile("com.google.protobuf_protobuf-java-util_3.6.1.html"); Nodes bomCoordinatesNodes = document.query("//p[@class='bom-coordinates']"); Assert.assertEquals(1, bomCoordinatesNodes.size()); Assert.assertEquals( "BOM: com.google.cloud:libraries-bom:1.0.0", bomCoordinatesNodes.get(0).getValue()); }
Example #23
Source File: DashboardUnavailableArtifactTest.java From cloud-opensource-java with Apache License 2.0 | 4 votes |
@Test public void testDashboardWithRepositoryException() throws IOException, TemplateException, ParsingException { Configuration configuration = DashboardMain.configureFreemarker(); Artifact validArtifact = new DefaultArtifact("io.grpc:grpc-context:1.15.0"); ArtifactResults validArtifactResult = new ArtifactResults(validArtifact); validArtifactResult.addResult(DashboardMain.TEST_NAME_UPPER_BOUND, 0); validArtifactResult.addResult(DashboardMain.TEST_NAME_DEPENDENCY_CONVERGENCE, 0); validArtifactResult.addResult(DashboardMain.TEST_NAME_GLOBAL_UPPER_BOUND, 0); Artifact invalidArtifact = new DefaultArtifact("io.grpc:nonexistent:jar:1.15.0"); ArtifactResults errorArtifactResult = new ArtifactResults(invalidArtifact); errorArtifactResult.setExceptionMessage( "Could not find artifact io.grpc:nonexistent:jar:1.15.0 in central" + " (https://repo1.maven.org/maven2/)"); List<ArtifactResults> table = new ArrayList<>(); table.add(validArtifactResult); table.add(errorArtifactResult); DashboardMain.generateDashboard( configuration, outputDirectory, table, ImmutableList.of(), ImmutableMap.of(), new ClassPathResult(LinkedListMultimap.create(), ImmutableList.of()), bom); Path generatedHtml = outputDirectory.resolve("artifact_details.html"); Assert.assertTrue(Files.isRegularFile(generatedHtml)); Document document = builder.build(generatedHtml.toFile()); Assert.assertEquals("en-US", document.getRootElement().getAttribute("lang").getValue()); Nodes tr = document.query("//tr"); Assert.assertEquals( "The size of rows in table should match the number of artifacts + 1 (header)", tr.size(),table.size() + 1); Nodes tdForValidArtifact = tr.get(1).query("td"); Assert.assertEquals( Artifacts.toCoordinates(validArtifact), tdForValidArtifact.get(0).getValue()); Element firstResult = (Element) (tdForValidArtifact.get(2)); Truth.assertThat(firstResult.getValue().trim()).isEqualTo("PASS"); Truth.assertThat(firstResult.getAttributeValue("class")).isEqualTo("pass"); Nodes tdForErrorArtifact = tr.get(2).query("td"); Assert.assertEquals( Artifacts.toCoordinates(invalidArtifact), tdForErrorArtifact.get(0).getValue()); Element secondResult = (Element) (tdForErrorArtifact.get(2)); Truth.assertThat(secondResult.getValue().trim()).isEqualTo("UNAVAILABLE"); Truth.assertThat(secondResult.getAttributeValue("class")).isEqualTo("unavailable"); }
Example #24
Source File: HtmlBuilder.java From caja with Apache License 2.0 | 3 votes |
/** * Parse a fragment from SAX <code>InputSource</code>. * @param is the <code>InputSource</code> * @param context the name of the context element * @return the fragment * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang */ public Nodes buildFragment(InputSource is, String context) throws IOException, ParsingException { xomTreeBuilder.setFragmentContext(context.intern()); tokenize(is); return xomTreeBuilder.getDocumentFragment(); }
Example #25
Source File: HtmlBuilder.java From caja with Apache License 2.0 | 3 votes |
/** * Parse from <code>InputStream</code>. * @param stream the stream * @param uri the base URI * @return the document * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang * @see nu.xom.Builder#build(java.io.InputStream, java.lang.String) */ @Override public Document build(InputStream stream, String uri) throws ParsingException, ValidityException, IOException { InputSource is = new InputSource(stream); is.setSystemId(uri); return build(is); }
Example #26
Source File: HtmlBuilder.java From caja with Apache License 2.0 | 3 votes |
/** * Parse from <code>Reader</code>. * @param stream the reader * @param uri the base URI * @return the document * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang * @see nu.xom.Builder#build(java.io.Reader, java.lang.String) */ @Override public Document build(Reader stream, String uri) throws ParsingException, ValidityException, IOException { InputSource is = new InputSource(stream); is.setSystemId(uri); return build(is); }
Example #27
Source File: HtmlBuilder.java From caja with Apache License 2.0 | 2 votes |
/** * Parse from SAX <code>InputSource</code>. * @param is the <code>InputSource</code> * @return the document * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang */ public Document build(InputSource is) throws ParsingException, IOException { xomTreeBuilder.setFragmentContext(null); tokenize(is); return xomTreeBuilder.getDocument(); }
Example #28
Source File: HtmlBuilder.java From caja with Apache License 2.0 | 2 votes |
/** * Parse from <code>File</code>. * @param file the file * @return the document * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang * @see nu.xom.Builder#build(java.io.File) */ @Override public Document build(File file) throws ParsingException, ValidityException, IOException { return build(new FileInputStream(file), file.toURI().toASCIIString()); }
Example #29
Source File: HtmlBuilder.java From caja with Apache License 2.0 | 2 votes |
/** * Parse from <code>InputStream</code>. * @param stream the stream * @return the document * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang * @see nu.xom.Builder#build(java.io.InputStream) */ @Override public Document build(InputStream stream) throws ParsingException, ValidityException, IOException { return build(new InputSource(stream)); }
Example #30
Source File: HtmlBuilder.java From caja with Apache License 2.0 | 2 votes |
/** * Parse from <code>Reader</code>. * @param stream the reader * @return the document * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang * @see nu.xom.Builder#build(java.io.Reader) */ @Override public Document build(Reader stream) throws ParsingException, ValidityException, IOException { return build(new InputSource(stream)); }