jaxp

Querying an HTML page with XPath in Java

早过忘川 提交于 2019-12-12 02:22:56
问题 Can anyone advise me a library for Java that allows me to perform an XPath Query over an html page? I tried using JAXP but it keeps giving me a strange error that I cannot seem to fix (thread "main" java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd). Thank you very much. EDIT I found this: // Create a new SAX Parser factory SAXParserFactory factory = SAXParserFactory.newInstance(); // Turn on validation factory

Java servlets: xml validation against xsd

我们两清 提交于 2019-12-11 07:42:09
问题 I have servlet which uses utility packaged in .jar archive: @Override public void init() throws ServletException { ... try (InputStream stream = getClass().getResourceAsStream("/fileToParse.xml")) { App.check(stream); } catch (Exception e) { throw new ServletException(e); } ... } This utility takes xml file stream, performs validation against xsd schema and parses it: public class App { private static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"

Can we do XSLT 2.0 with Netbeans 7?

夙愿已清 提交于 2019-12-10 11:29:30
问题 In its current form, Netbeans only supports XSLT 1.0 and does not support XSLT 2.0. How do we use XSLT 2.0 with Netbeans 7? 回答1: How to make Saxon the JRE-installation-default XSLT Processor: (So not only for Netbeans, other Java applications might be impacted as well.) Get Saxon for Java (there are different editions, pick the one suitable for you) and copy saxonXYZ.jar to the jre/lib/ext dir. In the jre/lib dir create a jaxp.properties file with following content: javax.xml.transform

Moving files after failed validation (Java)

早过忘川 提交于 2019-12-07 12:50:09
问题 We are validating XML files and depending on the result of the validation we have to move the file into a different folder. When the XML is valid the validator returns a value and we can move the file without a problem. Same thing happens when the XML is not valid according to the schema. If however the XML is not well formed the validator throws an exception and when we try to move the file, it fails. We believe there is still a handle in the memory somewhere that keeps hold of the file. We

I need to parse non well-formed xml data (HTML)

早过忘川 提交于 2019-12-07 05:42:25
问题 I have some non well-formed xml (HTML) data in JAVA, I used JAXP Dom, but It complains. The Question is :Is there any way to use JAXP to parse such documents ?? I have a file containing data such as : <employee> <name value="ahmed" > <!-- note, this element is not closed, So it is not well-formed xml--> </employee> 回答1: Not really. JAXP wants well-formed markup. Have you considered the Cyberneko HTML Parser? We've been very successful with it at our shop. EDIT: I see you are wanting to parse

Is DocumentBuilderFactory thread-safe in Java 5+?

☆樱花仙子☆ 提交于 2019-12-06 17:04:23
问题 The Java 1.4 doc for javax.xml.parsers.DocumentBuilderFactory states in no uncertain terms: An implementation of the DocumentBuilderFactory class is NOT guaranteed to be thread safe. It is up to the user application to make sure about the use of the DocumentBuilderFactory from more than one thread. Alternatively the application can have one instance of the DocumentBuilderFactory per thread. An application can use the same instance of the factory to obtain one or more instances of the

JAXP Transformer via DOMSource returns stylesheet

别等时光非礼了梦想. 提交于 2019-12-06 13:24:57
I'm having a strange problem and can't seem to find any solution. I'm simply trying to apply an XSLT stylesheet to an XML file (in this case, SPARQL query results formatted as XML, but any other XML file gives the same result). In this case, I need to create the transformer by re-using an already loaded XML document, via DOMSource. You can find the code below (simplified; normally, the stylesheet document comes from elsewhere): TransformerFactory factory = TransformerFactory.newInstance(); Document stylesheet = db.parse(new File("C:/workspace_5/stylesheet.xml")); Transformer xformer = factory

Can we do XSLT 2.0 with Netbeans 7?

穿精又带淫゛_ 提交于 2019-12-06 04:30:46
In its current form, Netbeans only supports XSLT 1.0 and does not support XSLT 2.0. How do we use XSLT 2.0 with Netbeans 7? How to make Saxon the JRE-installation-default XSLT Processor: (So not only for Netbeans, other Java applications might be impacted as well.) Get Saxon for Java (there are different editions, pick the one suitable for you) and copy saxonXYZ.jar to the jre/lib/ext dir. In the jre/lib dir create a jaxp.properties file with following content: javax.xml.transform.TransformerFactory = net.sf.saxon.TransformerFactoryImpl (Restart Netbeans.) Check success by doing an XSL

Moving files after failed validation (Java)

旧城冷巷雨未停 提交于 2019-12-05 20:53:59
We are validating XML files and depending on the result of the validation we have to move the file into a different folder. When the XML is valid the validator returns a value and we can move the file without a problem. Same thing happens when the XML is not valid according to the schema. If however the XML is not well formed the validator throws an exception and when we try to move the file, it fails. We believe there is still a handle in the memory somewhere that keeps hold of the file. We tried putting System.gc() before moving the file and that sorted the problem but we can't have System

Detecting System.setProperty method invocations

霸气de小男生 提交于 2019-12-05 02:08:02
问题 I'm facing a conundrum here. One of the applications that I've developed is loading an incorrect implementation of the DocumentBuilderFactory class of JAXP. This behavior was later deduced to be resulting from another class in different application built by a different team/company. The said class had changed the preferred DocumentBuilderFactory class upon loading, by inclusion of a static block similar to the one below: static { System.setProperty("javax.xml.parsers.DocumentBuilderFactory",