n32303
n32303

Reputation: 829

How to add definiton for xsi namespace with saxon .NET api

I am trying to add definiton for xsi namespace into saxon .NET api.

I have already used this - but this does not help:

Processor xmlProcessor = new Processor();
SchemaManager manager1 = xmlProcessor.SchemaManager;
SchemaValidator validator = manager1.NewSchemaValidator();

DocumentBuilder builder = xmlProcessor.NewDocumentBuilder();
XdmNode xdmNode = builder.Build(xmlDocument);
validator.SetSource(xdmNode);
XPathCompiler compiler = xmlProcessor.NewXPathCompiler();

I need this for parsing xpath like this:

substring-before(substring-after(//IzdaniRacunEnostavni/@xsi:noNamespaceSchemaLocation,'http://www.gzs.si/e-poslovanje/sheme/'))

And if this is not supported in Home Edition, are there any free external liubrarires that fully support xpath 2.0?

Upvotes: 1

Views: 208

Answers (1)

n32303
n32303

Reputation: 829

I have found a solution to my question:

You must use compiler.DeclareNamespace method .

    Processor xmlProcessor = new Processor();
    DocumentBuilder builder = xmlProcessor.NewDocumentBuilder();
    XdmNode xdmNode = builder.Build(xmlDocument);
    XPathCompiler compiler = xmlProcessor.NewXPathCompiler();
    compiler.DeclareNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");

Upvotes: 3

Related Questions