Note that there are some explanatory texts on larger screens.

plurals
  1. POXML Namespace is getting issues for parsing the file in XPath + java
    primarykey
    data
    text
    <p>I have an XML likewise </p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;QDTM_IN300301QD ITSVersion="XML_1.0" xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 QDTM_IN300401QD.xsd "&gt; &lt;controlActEvent classCode="CACT" moodCode="EVN"&gt; &lt;code code="QDTM_TE300401QD"&gt; &lt;/code&gt; &lt;statusCode code="Active" /&gt; &lt;subject contextConductionInd="true" contextControlCode="ON" typeCode="SUBJ"&gt; &lt;registrationEvent classCode="REG" moodCode="EVN"&gt; &lt;statusCode code="token" /&gt; &lt;subject contextControlCode="AN" typeCode="SBJ"&gt; &lt;testCodeIdentifier classCode="ROL"&gt; &lt;playingTestCodeDetails classCode="ENT" determinerCode="INSTANCE"&gt; &lt;code code="6399Z" codeSystemName="QTIM" codeSystemVersion="Updated"&gt; &lt;originalText&gt;&lt;![CDATA[CBC (includes Differential and Platelets)]]&gt;&lt;/originalText&gt; &lt;translation codeSystemName="DOSCATALOGNAMEHTMLENABLED"&gt; &lt;originalText&gt;&lt;![CDATA[CBC (includes Differential and Platelets)]]&gt;&lt;/originalText&gt; &lt;/translation&gt; &lt;/code&gt; &lt;/playingTestCodeDetails&gt; &lt;/testCodeIdentifier&gt; &lt;/subject&gt; &lt;/registrationEvent&gt; &lt;/subject&gt; &lt;/controlActEvent&gt; &lt;/QDTM_IN300301QD&gt; </code></pre> <p>JAVA CODE:</p> <pre><code>package com.parse; import java.io.IOException; import java.util.Iterator; import javax.xml.namespace.NamespaceContext; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Document; import org.xml.sax.SAXException; public class ParseXPath { public String parseXML(String fileName) { fileName = "D://projects//Draft.xml"; DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(true); DocumentBuilder builder; Document doc; try { builder = domFactory.newDocumentBuilder(); doc = builder.parse(fileName); XPath xpath = XPathFactory.newInstance().newXPath(); xpath.setNamespaceContext(new NamespaceContext(){public String getNamespaceURI(String prefix) { return "urn:hl7-org:v3"; } public String getPrefix(String namespaceURI) { return null; // we are not using this. } public Iterator getPrefixes(String namespaceURI) { return null; // we are not using this. } }); String expr="//QDTM_IN300401QD/controlActEvent/subject/registrationEvent/subject/testCodeIdentifier/playingTestCodeDetails/code/translation[@codeSystemName='DOSCATALOGNAMEHTMLENABLED']/originalText/text()"; String result = xpath.evaluate(expr, doc); System.out.println("Result --&gt; "+result); return result; } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (XPathExpressionException e) { // TODO Auto-generated catch block e.printStackTrace(); } return fileName; public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException { ParseBUXpath p = new ParseBUXpath(); p.parseRelatedTestXML("test"); } } </code></pre> <p>I am facing this issue in Namespace thing in XML. When the xml is having "xmlns="urn:hl7-org:v3" then the xpath query doesnt get me the data. For supressing that i have written the code in java and removed the line from XML.</p> <p>I need to parse the XML and get the data without deleting the namespace part from the XML. Is this a problem related to xsd or it is not getting the xsd mentioned?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload