My guess would be that Saxon is simply passing on the error returned by the XmlReader. Have you tried seeing whether the problem occurs when Saxon is not involved: in other words, with these settings, is the XmlReader capable of reading the file if you take Saxon out of the equation? If it is, then we need to look to see what Saxon is doing differently from your test application that causes it to fail. But if the XmlReader fails even when Saxon isn't involved, then it's hard to see how I can help you.

Michael Kay
Saxonica

On 22/06/2010 14:14, Mariappan, Jawahar Kaliraj wrote:
Validating XML document using remote XSD and Saxon.Net 9.2

Hi,

I am trying to validate a XML document using remote XSD and saxon.Net 9.2. Though the credentials to access the remote server is set, the SchemaManager.Compile(XmlReader) is returning the following error message: net.sf.saxon.type.SchemaException: net.sf.saxon.trans.XPathException: javax.xml.transform.TransformerException: The remote server returned an error: (401) Unauthorized.

The C# code snippet is given below. For info, Saxon API is registered on the GAC and the Saxon home directory has been set. At the moment, I am using evaluation version. On successful validation and with satisfactory performance, I would like to buy the licensed version.

Please help.

Thanks

Jawahar

Processor processor = new Processor(true);

      SchemaManager manager = processor.SchemaManager;

      manager.ErrorList = new ArrayList();

      XmlReaderSettings schemaReaderSettings = new XmlReaderSettings();

      XmlUrlResolver resolver = new XmlUrlResolver();

      resolver.Credentials = new NetworkCredential(<UserName to access the remote server>,<Password to access the remote server>);

      schemaReaderSettings.XmlResolver = resolver;

      XmlReader schemaReader = XmlReader.Create(<remote http path to xsd file>, schemaReaderSettings);

     

      try

      {

        // Note: Visual studio debug watch indicates that the instance schemaReader.Settings.XmlResolve.Credentials is Null,

}

      catch (Exception e)

      {

        Console.WriteLine(e);

        Console.WriteLine("Schema compilation failed with " + manager.ErrorList.Count + " errors");

        foreach (StaticError error in manager.ErrorList)

        {

          Console.WriteLine("At line " + error.LineNumber + ": " + error.Message);

        }

        Console.ReadLine();

        return;

      }


      // Use this to validate an instance document

      SchemaValidator validator = manager.NewSchemaValidator();

      Uri instanceUri = new Uri(<Local source xml file to validate>);

      validator.SetSource(instanceUri);

      validator.ErrorList = new ArrayList();

      XdmDestination psvi = new XdmDestination();

      validator.SetDestination(psvi);

      try

      {

        validator.Run();

      }

      catch (Exception e)

      {

        Console.WriteLine(e);

        Console.WriteLine("Instance validation failed with " + validator.ErrorList.Count + " errors");

        foreach (StaticError error in validator.ErrorList)

        {

          Console.WriteLine("At line " + error.LineNumber + ": " + error.Message);

        }

        return;

      }

***********************************************************************************************

This email, including any attachment, is confidential and may be legally privileged. If you are not the intended recipient or if you have received this email in error, please inform the sender immediately by reply and delete all copies from your system. Do not retain, copy, disclose, distribute or otherwise use any of its contents.

 

Whilst we have taken reasonable precautions to ensure that this email has been swept for computer viruses, we cannot guarantee that this email does not contain such material and we therefore advise you to carry out your own virus checks. We do not accept liability for any damage or losses sustained as a result of such material.

 

Please note that incoming and outgoing email communications passing through our IT systems may be monitored and/or intercepted by us solely to determine whether the content is business related and compliant with company standards.

***********************************************************************************************

The Stationery Office Limited is registered in England No. 3049649 at 10 Eastbourne Terrace, London, W2 6LG

 

------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/saxon-help