|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Newbie Q: Saxon-B, xmlnsMichael Malak michaelmalak at yahoo.comTue 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\" xmlns=\"http://www.w3.org/1999/xhtml\">" + "<head><title>Hello World</title></head></html>"; string query = "data(/html/head/title)"; Processor processor = new Processor(); XmlDocument input = new XmlDocument(); input.LoadXml(xhtml); XQueryCompiler compiler = processor.NewXQueryCompiler(); XQueryExecutable exp = compiler.Compile(query); XQueryEvaluator eval = exp.Load(); eval.ContextItem = processor.NewDocumentBuilder().Build(new XmlNodeReader(input)); Serializer qout = new Serializer(); StringWriter sw = new StringWriter(); qout.SetOutputProperty(Serializer.METHOD, "xml"); qout.SetOutputWriter(sw); eval.Run(qout); Console.WriteLine(sw); 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 as-is?
|
Purchase Stylus Studio Online Today!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






