[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Newbie Q: Saxon-B, xmlns

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


  Newbie Q: Saxon-B
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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.