HELP IN SAME LINE NUMBER.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

HELP IN SAME LINE NUMBER.

RamKumarDinesh Thillai

 
hi,
  if i have a node that i got and i need to get where it actually locates?how is this possible with the same by using Configuration or else i have to follow some other format
for eg.
xml file is
  <root>
    <pubinfo>
      <pubname>dddd s</pubname>
      <pubnum>19393</pubnum>
  </root>

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
     
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputSource inputSrc = new InputSource(new FileInputStream(new File(xmlFileToLoad)));
        Document xmlDoc = builder.parse(inputSrc);
            NodeList dd=xmlDoc.getElementsByTagName("pubnum");
            Node dd1=dd.item(0);
NodeInfo nodeInfo = (NodeInfo)dd1.getFirstChild();
        System.out.println(nodeInfo.getLineNumber()); // will this return the value 4.


it is not giving me..
the one u told for xpath also i tried but it is returning 0 i think bcauz it is having the whole document in the nodeinfo it is retunrning 0.

Configuration config = new Configuration();            config.setLineNumbering(true);
XPathEvaluator xpath = new XPathEvaluator(config);         
NodeInfo doc = xpath.setSource(new StreamSource((new File xmlFileToLoad))));

System.out.println("The Line Number "+doc.getLineNumber());

what could be wrong in my code..?


ram.t



Reply | Threaded
Open this post in threaded view
|

RE: HELP IN SAME LINE NUMBER.

Michael Kay
Sorry, but I have no idea how this question relates to your previous question. You seem to be asking the same question again in a slightly different way: I can only refer you to the previous answer.
 
 
Michael Kay
Saxonica Limited


From: [hidden email] [mailto:[hidden email]] On Behalf Of RamKumarDinesh Thillai
Sent: 06 October 2005 07:30
To: [hidden email]
Subject: [saxon] HELP IN SAME LINE NUMBER.


hi,
  if i have a node that i got and i need to get where it actually locates?how is this possible with the same by using Configuration or else i have to follow some other format
for eg.
xml file is
  <root>
    <pubinfo>
      <pubname>dddd s</pubname>
      <pubnum>19393</pubnum>
  </root>

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
     
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputSource inputSrc = new InputSource(new FileInputStream(new File(xmlFileToLoad)));
        Document xmlDoc = builder.parse(inputSrc);
            NodeList dd=xmlDoc.getElementsByTagName("pubnum");
            Node dd1=dd.item(0);
NodeInfo nodeInfo = (NodeInfo)dd1.getFirstChild();
        System.out.println(nodeInfo.getLineNumber()); // will this return the value 4.


it is not giving me..
the one u told for xpath also i tried but it is returning 0 i think bcauz it is having the whole document in the nodeinfo it is retunrning 0.

Configuration config = new Configuration();            config.setLineNumbering(true);
XPathEvaluator xpath = new XPathEvaluator(config);         
NodeInfo doc = xpath.setSource(new StreamSource((new File xmlFileToLoad))));

System.out.println("The Line Number "+doc.getLineNumber());

what could be wrong in my code..?


ram.t