[xquery-talk] Newbie Q: Saxon-B, xmlns

Michael Malak michaelmalak at yahoo.com
Tue Jul 3 14:50:40 PDT 2007

I'm attempting to use Saxon-B with C#/.NET.

string xhtml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
 + "<html _xml3a_lang=\"en\" lang=\"en\"
 + "<head><title>Hello World</title></head></html>";

string query = "data(/html/head/title)";

Processor processor = new Processor();
XmlDocument input = new XmlDocument();
XQueryCompiler compiler = processor.NewXQueryCompiler();
XQueryExecutable exp = compiler.Compile(query);
XQueryEvaluator eval = exp.Load();
eval.ContextItem = processor.NewDocumentBuilder().Build(new
Serializer qout = new Serializer();
StringWriter sw = new StringWriter();
qout.SetOutputProperty(Serializer.METHOD, "xml");


When I execute this as-is, I get back an empty XML document.  If I
change the xmlns attribute to be xmlns:html, it works.  I presume
that's because that removes the HTML elements out of the default
namespace and Saxon-B is not schema aware so it happily processes the
HTML tags as if they're not HTML.

How can I change my query so that it works with the source XHTML above

More information about the talk mailing list