With this interface, Saxon will create an XMLReader, supplying an ErrorHandler that writes error messages to System.err. To override this behaviour, you need to create the XMLReader yourself. Use the method

public XQItem createItemFromDocument(Source value, XQItemType type)

supplying as the value argument something like this:

XMLReader parser = ....
parser.setErrorHandler(new MyErrorHandler());
SAXSource source = new SAXSource(parser, new InputSource(reader, fileName));
... createItemFromDocument(source, null);

One way to get an XMLReader is by using the JAXP SAXParserFactory mechanism, though this is rather clumsy and inefficient; if you know which XML parser you want to use then it's better to instantiate it directly.

Michael Kay
Saxonica

On 08/08/2011 07:03, Kunal Chauhan wrote:
Hello Michael,
 
I am using XQJ API.
and I mentioned code below which I implemented.
give me your suggestions.
 
CODE:
 
public static XQItem getXQItem(String fileName){
  XQItem itemDoc = null;
  InputStream reader  = null;
  SaxonXQConnection con = null;
  try {
   reader = XMLReader.getInputStreamReader(fileName);
   con = (SaxonXQConnection)XQueryConnection.getConnection();
   itemDoc = con.createItemFromDocument(reader, null, null);
   reader.close();
  }
  catch (XQException e) {
   e.printStackTrace();
  }
  catch (IOException e) {
   e.printStackTrace();
  }
  return itemDoc;
 }
 
 
Thanks & Regards,
Kunal Chauhan
 

 

 

  

 

 

 



On Fri, Aug 5, 2011 at 8:00 PM, Michael Kay <mike@saxonica.com> wrote:
You need to supply your own ErrorHandler to the XML parser. This means you will need to create the XML parser (class XMLReader) yourself, which you can then include in a SAXSource that is supplied as the input to your transformation.

Michael Kay
Saxonica


On 05/08/2011 15:16, Kunal Chauhan wrote:
Hello,
 
I am using saxon9he as an XML Processor.
Whenever I try to parse an Invalid XML file at that time, On console I am able to get line number and column number where an error exist within document.
 
But I want to catch that exception and want to print line number and column number where an error exist.
 
 
for example,
On console it gives following output
 

Error on line 3 column 7

SXXP0003: Error reported by XML parser: Element type "aba" must be followed by either

attribute specifications, ">" or "/>".

 

I want this line and column number to show proper error message.

How can I achieve this ?
 

Regards,
--
Kunal Chauhan
[+918655517141]
[+919904983614]

------------------------------------------------------------------------------ BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA The must-attend event for mobile developers. Connect with experts. Get tools for creating Super Apps. See the latest technologies. Sessions, hands-on labs, demos & much more. Register early & save! http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help



--
Kunal Chauhan
mail4ck@gmail.com
[+918655517141]
[+919904983614]

------------------------------------------------------------------------------ BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA The must-attend event for mobile developers. Connect with experts. Get tools for creating Super Apps. See the latest technologies. Sessions, hands-on labs, demos & much more. Register early & save! http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/saxon-help