ok micheal

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

ok micheal

RamKumarDinesh Thillai

 
which one to use for parsing a document?
i used this
System.setProperty("javax.xml.parsers.DocumentBuilderFactory","net.sf.saxon.dom.DocumentBuilderFactoryImpl");

but still it has the problem.is there anyother way to use dom so that it can be done to get the line number?



Reply | Threaded
Open this post in threaded view
|

Re: ok micheal

RamKumarDinesh Thillai

i used this code,
  Configuration config = new Configuration();
            config.setLineNumbering(true);
     
           
            XPathEvaluator xpath = new XPathEvaluator(config);
            NodeInfo doca = xpath.setSource(new StreamSource((new File(xmlFileToLoad))));
            // String expression = "//artfront/artinfo/pubinfo/pubname";
            List list = xpath.evaluate("//*");
            for (int i=0; i<list.size(); i++) {
                NodeInfo element = (NodeInfo)list.get(i);
                System.out.println("Element " + element.getDisplayName() + " at line " + element.getLineNumber());
            }

it reads all the node and gives line number as -1 to all? :(:(
i dont know where i am going wrong..

On Sat, 08 Oct 2005 RamKumarDinesh Thillai wrote :
>
>which one to use for parsing a document?
>i used this
>System.setProperty("javax.xml.parsers.DocumentBuilderFactory","net.sf.saxon.dom.DocumentBuilderFactoryImpl");
>
>but still it has the problem.is there anyother way to use dom so that it can be done to get the line number?



Reply | Threaded
Open this post in threaded view
|

Re: Re: ok micheal

RamKumarDinesh Thillai
In reply to this post by RamKumarDinesh Thillai

  i tried this code for my testing purpose
            Configuration config = new Configuration();
            config.setLineNumbering(true);
            XPathEvaluator xpath = new XPathEvaluator(config);
            NodeInfo doca = xpath.setSource(new StreamSource((new File(xmlFileToLoad))));
            List list = xpath.evaluate("//*");
            for (int i=0; i<list.size(); i++) {
                NodeInfo element = (NodeInfo)list.get(i);
                if((element.getDisplayName().equals("emph")) && !element.hasChildNodes())
                System.out.println("Element " + element.getDisplayName() + " at line " + element.getLineNumber());
            }

here i am checking for any empty emph element is there.

it is there but the result i got through this is
"Element emph at line -1"

I hope u got my problem.dont you?


On Sat, 08 Oct 2005 RamKumarDinesh Thillai wrote :
>i used this code,
>  ¬†Configuration config = new Configuration();
>            config.setLineNumbering(true);
>
>
>            XPathEvaluator xpath = new XPathEvaluator(config);
>            NodeInfo doca = xpath.setSource(new StreamSource((new File(xmlFileToLoad))));
>            // String expression = "//artfront/artinfo/pubinfo/pubname";
>            List list = xpath.evaluate("//*");
>            for (int i=0; i<list.size(); i++) {
>                NodeInfo element = (NodeInfo)list.get(i);
>                System.out.println("Element " + element.getDisplayName() + " at line " + element.getLineNumber());
>            }
>
>it reads all the node and gives line number as -1 to all? :(:(
>i dont know where i am going wrong..
>
>On Sat, 08 Oct 2005 RamKumarDinesh Thillai wrote :
> >
> >which one to use for parsing a document?
> >i used this
> >System.setProperty("javax.xml.parsers.DocumentBuilderFactory","net.sf.saxon.dom.DocumentBuilderFactoryImpl");
> >
> >but still it has the problem.is there anyother way to use dom so that it can be done to get the line number?



Reply | Threaded
Open this post in threaded view
|

RE: Re: Problem with line-numbers

Michael Kay
I can't see what you're doing wrong, but when I run this code:
 
    public static void main(String[] args) throws Exception {
        Configuration config = new Configuration();
        config.setLineNumbering(true);
        XPathEvaluator xpath = new net.sf.saxon.xpath.XPathEvaluator(config);
        NodeInfo doca = xpath.setSource(new StreamSource((new File(args[0]))));
        List list = xpath.evaluate("//*");
        for (int i=0; i<list.size(); i++) {
            NodeInfo element = (NodeInfo)list.get(i);
            System.out.println("Element " + element.getDisplayName() + " at line " + element.getLineNumber());
        }
    }
 
with the standard books.xml file supplied as args[0], the output looks like this:
 
Element BOOKLIST at line 4
Element BOOKS at line 5
Element ITEM at line 6
Element TITLE at line 7
Element AUTHOR at line 8
Element PUBLISHER at line 9
Element PUB-DATE at line 10....

The only thing I can think of is that you're using an XML parser that doesn't report line numbers; but I've
never come across that problem (and Saxon relies on the line numbers for reporting errors in stylesheets,
so it would be very noticeable).
 
Could you confirm you are using Saxon 8.5.1 - do
 
    System.out.println("Saxon Version " + net.sf.saxon.Version.getProductTitle());
 
Perhaps you could send me a complete standalone program that demonstrates the problem, with full details of the environment in which you are running it.
 
By the way, my name is Michael - capital M, and the "a" comes before the "e". And it's helpful to use a subject line that enables people to recognize whether the thread is relevant to them.
 
Michael Kay


From: [hidden email] [mailto:[hidden email]] On Behalf Of RamKumarDinesh Thillai
Sent: 08 October 2005 05:28
To: [hidden email]
Subject: Re: Re: [saxon] ok micheal

  i tried this code for my testing purpose
            Configuration config = new Configuration();
            config.setLineNumbering(true);
            XPathEvaluator xpath = new XPathEvaluator(config);
            NodeInfo doca = xpath.setSource(new StreamSource((new File(xmlFileToLoad))));
            List list = xpath.evaluate("//*");
            for (int i=0; i<list.size(); i++) {
                NodeInfo element = (NodeInfo)list.get(i);
                if((element.getDisplayName().equals("emph")) && !element.hasChildNodes())
                System.out.println("Element " + element.getDisplayName() + " at line " + element.getLineNumber());
            }

here i am checking for any empty emph element is there.

it is there but the result i got through this is
"Element emph at line -1"

I hope u got my problem.dont you?


On Sat, 08 Oct 2005 RamKumarDinesh Thillai wrote :


>i used this code,
>   Configuration config = new Configuration();
>            config.setLineNumbering(true);
>
>
>            XPathEvaluator xpath = new XPathEvaluator(config);
>            NodeInfo doca = xpath.setSource(new StreamSource((new File(xmlFileToLoad))));
>            // String expression = "//artfront/artinfo/pubinfo/pubname";
>            List list = xpath.evaluate("//*");
>            for (int i=0; i<list.size(); i++) {
>                NodeInfo element = (NodeInfo)list.get(i);
>                System.out.println("Element " + element.getDisplayName() + " at line " + element.getLineNumber());
>            }
>
>it reads all the node and gives line number as -1 to all? :(:(
>i dont know where i am going wrong..
>
>On Sat, 08 Oct 2005 RamKumarDinesh Thillai wrote :
> >
> >which one to use for parsing a document?
> >i used this
> >System.setProperty("javax.xml.parsers.DocumentBuilderFactory","net.sf.saxon.dom.DocumentBuilderFactoryImpl");
> >
> >but still it has the problem.is there anyother way to use dom so that it can be done to get the line number?



Reply | Threaded
Open this post in threaded view
|

Re: RE: Re: Problem with line-numbers

RamKumarDinesh Thillai

 
yeah i tried this same code.

  but still i am getting the same -1 for all the elements.
i got the version as
  "Saxon Version SAXON 8.5.1 from Saxonica"
as u have asked me to try.and i am running my code from NetBeans. jdk1.5. i am using it. i have tried to run a sample xml file
called customer.xml.
<?xml version="1.0" encoding="UTF-8"?>
<Customers>
     <Customer id="C1">
          <Name>XYZ Plumbing</Name>
          <City>New Haven</City>
          <State>CT</State>
     </Customer>
     <Customer id="C2">
          <Name>Joes Bar and Grill</Name>
          <City>Waterbury</City>
          <State>CT</State>
     </Customer>
</Customers>

for this also it returns -1 for all the element.

and i am sorry for Michael abt the spelling.

On Mon, 10 Oct 2005 Michael Kay wrote :
>I can't see what you're doing wrong, but when I run this code:
>
>    public static void main(String[] args) throws Exception {
>        Configuration config = new Configuration();
>        config.setLineNumbering(true);
>        XPathEvaluator xpath = new
>net.sf.saxon.xpath.XPathEvaluator(config);
>        NodeInfo doca = xpath.setSource(new StreamSource((new
>File(args[0]))));
>        List list = xpath.evaluate("//*");
>        for (int i=0; i<list.size(); i++) {
>            NodeInfo element = (NodeInfo)list.get(i);
>            System.out.println("Element " + element.getDisplayName() + " at
>line " + element.getLineNumber());
>        }
>    }
>
>with the standard books.xml file supplied as args[0], the output looks like
>this:
>
>Element BOOKLIST at line 4
>Element BOOKS at line 5
>Element ITEM at line 6
>Element TITLE at line 7
>Element AUTHOR at line 8
>Element PUBLISHER at line 9
>Element PUB-DATE at line 10....
>
>
>The only thing I can think of is that you're using an XML parser that
>doesn't report line numbers; but I've
>never come across that problem (and Saxon relies on the line numbers for
>reporting errors in stylesheets,
>so it would be very noticeable).
>
>Could you confirm you are using Saxon 8.5.1 - do
>
>    System.out.println("Saxon Version " +
>net.sf.saxon.Version.getProductTitle());
>
>Perhaps you could send me a complete standalone program that demonstrates
>the problem, with full details of the environment in which you are running
>it.
>
>By the way, my name is Michael - capital M, and the "a" comes before the
>"e". And it's helpful to use a subject line that enables people to recognize
>whether the thread is relevant to them.
>
>Michael Kay
>http://www.saxonica.com/
>
>
>  _____
>
> From: [hidden email]
>[mailto:[hidden email]] On Behalf Of RamKumarDinesh
>Thillai
>Sent: 08 October 2005 05:28
>To: [hidden email]
>Subject: Re: Re: [saxon] ok micheal
>
>
>
>  i tried this code for my testing purpose
>            Configuration config = new Configuration();
>            config.setLineNumbering(true);
>            XPathEvaluator xpath = new XPathEvaluator(config);
>            NodeInfo doca = xpath.setSource(new StreamSource((new
>File(xmlFileToLoad))));
>            List list = xpath.evaluate("//*");
>            for (int i=0; i<list.size(); i++) {
>                NodeInfo element = (NodeInfo)list.get(i);
>                if((element.getDisplayName().equals("emph")) &&
>!element.hasChildNodes())
>                System.out.println("Element " + element.getDisplayName() + "
>at line " + element.getLineNumber());
>            }
>
>here i am checking for any empty emph element is there.
>
>it is there but the result i got through this is
>"Element emph at line -1"
>
>I hope u got my problem.dont you?
>
>
>On Sat, 08 Oct 2005 RamKumarDinesh Thillai wrote :
> >i used this code,
> >  Configuration config = new Configuration();
> >            config.setLineNumbering(true);
> >
> >
> >            XPathEvaluator xpath = new XPathEvaluator(config);
> >            NodeInfo doca = xpath.setSource(new StreamSource((new
>File(xmlFileToLoad))));
> >            // String expression = "//artfront/artinfo/pubinfo/pubname";
> >            List list = xpath.evaluate("//*");
> >            for (int i=0; i<list.size(); i++) {
> >                NodeInfo element = (NodeInfo)list.get(i);
> >                System.out.println("Element " + element.getDisplayName() +
>" at line " + element.getLineNumber());
> >            }
> >
> >it reads all the node and gives line number as -1 to all? :(:(
> >i dont know where i am going wrong..
> >
> >On Sat, 08 Oct 2005 RamKumarDinesh Thillai wrote :
> > >
> > >which one to use for parsing a document?
> > >i used this
> >
> >System.setProperty("javax.xml.parsers.DocumentBuilderFactory","net.sf.saxon
>.dom.DocumentBuilderFactoryImpl");
> > >
> > >but still it has the problem.is there anyother way to use dom so that it
>can be done to get the line number?
>
>
>
>
>
><http://adworks.rediff.com/cgi-bin/AdWorks/sigclick.cgi/www.rediff.com/signa
>ture-home.htm/1507191490@Middle5?PARTNER=3>
>



Reply | Threaded
Open this post in threaded view
|

RE: RE: Re: Problem with line-numbers

Michael Kay
I'm afraid I've reached the end of the line on this one. When something works in my own environment and doesn't work in yours, I have little choice but to invoke the clause in the terms and conditions that says "no support". Sorry about that.
 
Michael Kay


From: [hidden email] [mailto:[hidden email]] On Behalf Of RamKumarDinesh Thillai
Sent: 10 October 2005 04:27
To: [hidden email]
Subject: Re: RE: Re: [saxon] Problem with line-numbers


yeah i tried this same code.

  but still i am getting the same -1 for all the elements.
i got the version as
  "Saxon Version SAXON 8.5.1 from Saxonica"
as u have asked me to try.and i am running my code from NetBeans. jdk1.5. i am using it. i have tried to run a sample xml file
called customer.xml.
<?xml version="1.0" encoding="UTF-8"?>
<Customers>
     <Customer id="C1">
          <Name>XYZ Plumbing</Name>
          <City>New Haven</City>
          <State>CT</State>
     </Customer>
     <Customer id="C2">
          <Name>Joes Bar and Grill</Name>
          <City>Waterbury</City>
          <State>CT</State>
     </Customer>
</Customers>

for this also it returns -1 for all the element.

and i am sorry for Michael abt the spelling.

On Mon, 10 Oct 2005 Michael Kay wrote :


>I can't see what you're doing wrong, but when I run this code:
>
>    public static void main(String[] args) throws Exception {
>        Configuration config = new Configuration();
>        config.setLineNumbering(true);
>        XPathEvaluator xpath = new
>net.sf.saxon.xpath.XPathEvaluator(config);
>        NodeInfo doca = xpath.setSource(new StreamSource((new
>File(args[0]))));
>        List list = xpath.evaluate("//*");
>        for (int i=0; i<list.size(); i++) {
>            NodeInfo element = (NodeInfo)list.get(i);
>            System.out.println("Element " + element.getDisplayName() + " at
>line " + element.getLineNumber());
>        }
>    }
>
>with the standard books.xml file supplied as args[0], the output looks like
>this:
>
>Element BOOKLIST at line 4
>Element BOOKS at line 5
>Element ITEM at line 6
>Element TITLE at line 7
>Element AUTHOR at line 8
>Element PUBLISHER at line 9
>Element PUB-DATE at line 10....
>
>
>The only thing I can think of is that you're using an XML parser that
>doesn't report line numbers; but I've
>never come across that problem (and Saxon relies on the line numbers for
>reporting errors in stylesheets,
>so it would be very noticeable).
>
>Could you confirm you are using Saxon 8.5.1 - do
>
>    System.out.println("Saxon Version " +
>net.sf.saxon.Version.getProductTitle());
>
>Perhaps you could send me a complete standalone program that demonstrates
>the problem, with full details of the environment in which you are running
>it.
>
>By the way, my name is Michael - capital M, and the "a" comes before the
>"e". And it's helpful to use a subject line that enables people to recognize
>whether the thread is relevant to them.
>
>Michael Kay
>http://www.saxonica.com/
>
>
>  _____
>
> From: [hidden email]
>[mailto:[hidden email]] On Behalf Of RamKumarDinesh
>Thillai
>Sent: 08 October 2005 05:28
>To: [hidden email]
>Subject: Re: Re: [saxon] ok micheal
>
>
>
>  i tried this code for my testing purpose
>            Configuration config = new Configuration();
>            config.setLineNumbering(true);
>            XPathEvaluator xpath = new XPathEvaluator(config);
>            NodeInfo doca = xpath.setSource(new StreamSource((new
>File(xmlFileToLoad))));
>            List list = xpath.evaluate("//*");
>            for (int i=0; i<list.size(); i++) {
>                NodeInfo element = (NodeInfo)list.get(i);
>                if((element.getDisplayName().equals("emph")) &&
>!element.hasChildNodes())
>                System.out.println("Element " + element.getDisplayName() + "
>at line " + element.getLineNumber());
>            }
>
>here i am checking for any empty emph element is there.
>
>it is there but the result i got through this is
>"Element emph at line -1"
>
>I hope u got my problem.dont you?
>
>
>On Sat, 08 Oct 2005 RamKumarDinesh Thillai wrote :
> >i used this code,
> >  Configuration config = new Configuration();
> >            config.setLineNumbering(true);
> >
> >
> >            XPathEvaluator xpath = new XPathEvaluator(config);
> >            NodeInfo doca = xpath.setSource(new StreamSource((new
>File(xmlFileToLoad))));
> >            // String expression = "//artfront/artinfo/pubinfo/pubname";
> >            List list = xpath.evaluate("//*");
> >            for (int i=0; i<list.size(); i++) {
> >                NodeInfo element = (NodeInfo)list.get(i);
> >                System.out.println("Element " + element.getDisplayName() +
>" at line " + element.getLineNumber());
> >            }
> >
> >it reads all the node and gives line number as -1 to all? :(:(
> >i dont know where i am going wrong..
> >
> >On Sat, 08 Oct 2005 RamKumarDinesh Thillai wrote :
> > >
> > >which one to use for parsing a document?
> > >i used this
> >
> >System.setProperty("javax.xml.parsers.DocumentBuilderFactory","net.sf.saxon
>.dom.DocumentBuilderFactoryImpl");
> > >
> > >but still it has the problem.is there anyother way to use dom so that it
>can be done to get the line number?
>
>
>
>
>
><http://adworks.rediff.com/cgi-bin/AdWorks/sigclick.cgi/www.rediff.com/signa
>ture-home.htm/1507191490@Middle5?PARTNER=3>
>



Reply | Threaded
Open this post in threaded view
|

Re: RE: RE: Re: Problem with line-numbers

RamKumarDinesh Thillai
In reply to this post by Michael Kay

sorry mich.
  this is the code i am using

import java.io.*;
import javax.xml.parsers.*;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.*;
import net.sf.saxon.*;
import net.sf.saxon.dom.*;
import net.sf.saxon.om.*;
import net.sf.saxon.xpath.*;
import java.io.File;
import java.util.List;
import java.util.Iterator;

public class Check{
    public static void main(String[] args) throws Exception {
System.out.println("Saxon Version " + net.sf.saxon.Version.getProductTitle());
        Configuration config = new Configuration();
        config.setLineNumbering(true);
        XPathEvaluator xpath = new net.sf.saxon.xpath.XPathEvaluator(config);
        NodeInfo doca = xpath.setSource(new StreamSource((new File(args[0]))));
        List list = xpath.evaluate("//*");
        for (int i=0; i<list.size(); i++) {
            NodeInfo element = (NodeInfo)list.get(i);
            System.out.println("Element " + element.getDisplayName() + " at line " +

element.getLineNumber());
        }
    }
}

the sample xml i used to run
<?xml version="1.0" encoding="UTF-8"?>
<Customers>
<Customer id="C1">
<Name>XYZ Plumbing</Name>
<City>New Haven</City>
<State>CT</State>
</Customer>
<Customer id="C2">
<Name>Joes Bar and Grill</Name>
<City>Waterbury</City>
<State>CT</State>
</Customer>
<Customer id="C3">
<Name>ABC Pizza</Name>
<City>Hartford</City>
<State>CT</State>
</Customer>
<Customer id="C4">
<Name>A really goes here</Name>
<City>Southington</City>
<State>CT</State>
</Customer>
<Customer id="C5">
<Name>xxx</Name>
<City>xxx</City>
<State>CT</State>
</Customer>
</Customers>


the output i got when i executed as.
java -cp D:\saxon8-5\saxon8.jar;D:\saxon8-5\saxon8-dom.jar;D:\saxon8-5\saxon8-xpath.jar; Check D:\codesam\Customers.xml

Saxon Version SAXON 8.5.1 from Saxonica
Element Customers at line -
Element Customer at line -1
Element Name at line -1
Element City at line -1
Element State at line -1
Element Customer at line -1
Element Name at line -1
Element City at line -1
Element State at line -1
Element Customer at line -1
Element Name at line -1
Element City at line -1
Element State at line -1
Element Customer at line -1
Element Name at line -1
Element City at line -1
Element State at line -1
Element Customer at line -1
Element Name at line -1
Element City at line -1
Element State at line -1

this is what it returned
java version is jdk1.5.03

really i am blank.. and almost lost...




Reply | Threaded
Open this post in threaded view
|

RE: Re: Problem with line-numbers

Owen Rees
In reply to this post by Michael Kay
--On Sunday, October 09, 2005 22:14:11 +0100 Michael Kay wrote:

> I can't see what you're doing wrong, but when I run this code:
[snip]
> with the standard books.xml file supplied as args[0], the output looks
> like this:
>
> Element BOOKLIST at line 4

I can reproduce the line number problem with the test program, line numbers
are reported correctly for stylesheet errors using the same configuration.

Here is a little script to drive the test, the code enhanced to show
version numbers of both Java and Saxon and the start of the output. This is
from a run on Linux, I get the same result under Windows XP Pro (same Java
and Saxon versions).

> cat test.sh
export CLASSPATH=$S/saxon8.jar:$S/saxon8-xpath.jar:.
javac LineNumbers.java
java LineNumbers $S/samples/data/books.xml
> cat LineNumbers.java
import java.io.File;
import java.util.List;

import javax.xml.transform.stream.StreamSource;

import net.sf.saxon.Configuration;
import net.sf.saxon.om.NodeInfo;
import net.sf.saxon.xpath.XPathEvaluator;

public class LineNumbers {
    public static void main(String[] args) throws Exception {
        System.out.println(System.getProperty("java.version"));
        System.out.println("Saxon Version "
                + net.sf.saxon.Version.getProductTitle());
        Configuration config = new Configuration();
        config.setLineNumbering(true);
        XPathEvaluator xpath = new
net.sf.saxon.xpath.XPathEvaluator(config);
        NodeInfo doca = xpath.setSource(new StreamSource((new
File(args[0]))));
        List list = xpath.evaluate("//*");
        for (int i = 0; i < list.size(); i++) {
            NodeInfo element = (NodeInfo) list.get(i);
            System.out.println("Element " + element.getDisplayName()
                    + " at line " + element.getLineNumber());
        }
    }
}
> sh test.sh
1.5.0_05
Saxon Version SAXON 8.5.1 from Saxonica
Element BOOKLIST at line -1
Element BOOKS at line -1
...


--
Owen Rees
Hewlett Packard Laboratories, Bristol, UK



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: RE: Re: Problem with line-numbers

RamKumarDinesh Thillai
In reply to this post by Michael Kay

  yea rees,
    this is wht i too got. i dont know what Mr.Michael is saying anyother information or package to be installed.?Rees did u get any idea?


On Thu, 13 Oct 2005 Owen Rees wrote :
>--On Sunday, October 09, 2005 22:14:11 +0100 Michael Kay wrote:
>
>>I can't see what you're doing wrong, but when I run this code:
>[snip]
>>with the standard books.xml file supplied as args[0], the output looks
>>like this:
>>
>>Element BOOKLIST at line 4
>
>I can reproduce the line number problem with the test program, line numbers are reported correctly for stylesheet errors using the same configuration.
>
>Here is a little script to drive the test, the code enhanced to show version numbers of both Java and Saxon and the start of the output. This is from a run on Linux, I get the same result under Windows XP Pro (same Java and Saxon versions).
>
>>cat test.sh
>export CLASSPATH=$S/saxon8.jar:$S/saxon8-xpath.jar:.
>javac LineNumbers.java
>java LineNumbers $S/samples/data/books.xml
>>cat LineNumbers.java
>import java.io.File;
>import java.util.List;
>
>import javax.xml.transform.stream.StreamSource;
>
>import net.sf.saxon.Configuration;
>import net.sf.saxon.om.NodeInfo;
>import net.sf.saxon.xpath.XPathEvaluator;
>
>public class LineNumbers {
>    public static void main(String[] args) throws Exception {
>        System.out.println(System.getProperty("java.version"));
>        System.out.println("Saxon Version "
>                + net.sf.saxon.Version.getProductTitle());
>        Configuration config = new Configuration();
>        config.setLineNumbering(true);
>        XPathEvaluator xpath = new net.sf.saxon.xpath.XPathEvaluator(config);
>        NodeInfo doca = xpath.setSource(new StreamSource((new File(args[0]))));
>        List list = xpath.evaluate("//*");
>        for (int i = 0; i < list.size(); i++) {
>            NodeInfo element = (NodeInfo) list.get(i);
>            System.out.println("Element " + element.getDisplayName()
>                    + " at line " + element.getLineNumber());
>        }
>    }
>}
>>sh test.sh
>1.5.0_05
>Saxon Version SAXON 8.5.1 from Saxonica
>Element BOOKLIST at line -1
>Element BOOKS at line -1
>...
>
>
>-- Owen Rees
>Hewlett Packard Laboratories, Bristol, UK
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by:
>Power Architecture Resource Center: Free content, downloads, discussions,
>and more. http://solutions.newsforge.com/ibmarch.tmpl
>_______________________________________________
>saxon-help mailing list
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/saxon-help



Reply | Threaded
Open this post in threaded view
|

RE: Re: Problem with line-numbers

Michael Kay
In reply to this post by Owen Rees
Thanks for pursuing this. I've now reproduced it. It turns out to be
something that's broken in 8.5.1 but which I had fixed in my current build
without realizing it. Basically, XPathEvaluator.setSource() is using a
default Configuration rather than the Configuration that was used when
initializing the XPathEvaluator.

The following replacement code seems to do the trick:

import java.io.File;
import java.util.List;

import javax.xml.transform.stream.StreamSource;

import net.sf.saxon.Configuration;
import net.sf.saxon.om.NodeInfo;
import net.sf.saxon.xpath.XPathEvaluator;

public class LineNumbers {
    public static void main(String[] args) throws Exception {
        System.out.println(System.getProperty("java.version"));
        System.out.println("Saxon Version "
                + net.sf.saxon.Version.getProductTitle());
        Configuration config = new Configuration();
        config.setLineNumbering(true);
        XPathEvaluator xpath = new
net.sf.saxon.xpath.XPathEvaluator(config);
        //NodeInfo doca = xpath.setSource(new StreamSource((new
File(args[0]))));
        NodeInfo contextNode = net.sf.saxon.event.Builder.build(new
StreamSource((new File(args[0]))), null, config);
        xpath.setSource(contextNode);
        List list = xpath.evaluate("//*");
        for (int i = 0; i < list.size(); i++) {
            NodeInfo element = (NodeInfo) list.get(i);
            System.out.println("Element " + element.getDisplayName()
                    + " at line " + element.getLineNumber());
        }
    }
}

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Owen Rees
> Sent: 13 October 2005 14:05
> To: [hidden email]
> Subject: RE: Re: [saxon] Problem with line-numbers
>
> --On Sunday, October 09, 2005 22:14:11 +0100 Michael Kay wrote:
>
> > I can't see what you're doing wrong, but when I run this code:
> [snip]
> > with the standard books.xml file supplied as args[0], the
> output looks
> > like this:
> >
> > Element BOOKLIST at line 4
>
> I can reproduce the line number problem with the test
> program, line numbers
> are reported correctly for stylesheet errors using the same
> configuration.
>
> Here is a little script to drive the test, the code enhanced to show
> version numbers of both Java and Saxon and the start of the
> output. This is
> from a run on Linux, I get the same result under Windows XP
> Pro (same Java
> and Saxon versions).
>
> > cat test.sh
> export CLASSPATH=$S/saxon8.jar:$S/saxon8-xpath.jar:.
> javac LineNumbers.java
> java LineNumbers $S/samples/data/books.xml
> > cat LineNumbers.java
> import java.io.File;
> import java.util.List;
>
> import javax.xml.transform.stream.StreamSource;
>
> import net.sf.saxon.Configuration;
> import net.sf.saxon.om.NodeInfo;
> import net.sf.saxon.xpath.XPathEvaluator;
>
> public class LineNumbers {
>     public static void main(String[] args) throws Exception {
>         System.out.println(System.getProperty("java.version"));
>         System.out.println("Saxon Version "
>                 + net.sf.saxon.Version.getProductTitle());
>         Configuration config = new Configuration();
>         config.setLineNumbering(true);
>         XPathEvaluator xpath = new
> net.sf.saxon.xpath.XPathEvaluator(config);
>         NodeInfo doca = xpath.setSource(new StreamSource((new
> File(args[0]))));
>         List list = xpath.evaluate("//*");
>         for (int i = 0; i < list.size(); i++) {
>             NodeInfo element = (NodeInfo) list.get(i);
>             System.out.println("Element " + element.getDisplayName()
>                     + " at line " + element.getLineNumber());
>         }
>     }
> }
> > sh test.sh
> 1.5.0_05
> Saxon Version SAXON 8.5.1 from Saxonica
> Element BOOKLIST at line -1
> Element BOOKS at line -1
> ...
>
>
> --
> Owen Rees
> Hewlett Packard Laboratories, Bristol, UK
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads,
> discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Re: Problem with line-numbers

Owen Rees
--On Friday, October 14, 2005 11:17:59 +0100 Michael Kay wrote:

> The following replacement code seems to do the trick:

That works for me. Thanks.

--
Owen Rees
Hewlett Packard Laboratories, Bristol, UK



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: RE: Re: Problem with line-numbers

RamKumarDinesh Thillai
In reply to this post by Michael Kay

  yeah i am sorry mich. its my problem . its working fine.


On Fri, 14 Oct 2005 Owen Rees wrote :
>--On Friday, October 14, 2005 11:17:59 +0100 Michael Kay wrote:
>
>>The following replacement code seems to do the trick:
>
>That works for me. Thanks.
>
>-- Owen Rees
>Hewlett Packard Laboratories, Bristol, UK
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by:
>Power Architecture Resource Center: Free content, downloads, discussions,
>and more. http://solutions.newsforge.com/ibmarch.tmpl
>_______________________________________________
>saxon-help mailing list
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/saxon-help