To help with this, I will need to know what is in the DOM node (doc). Can you send a program that I can execute to demonstrate the problem?

It is possible to construct a DOM in which there are elements or attributes having a prefixed name, where the prefix is not declared in any containing element. That is, a DOM representing a non-namespace-well-formed document. If your DOM is not namespace-well-formed, Saxon will not be able to process it. It's quite possible that other products will be able to process it, either because they are deliberately more liberal in what they accept, or because they do less validation.

I don't think the email message you found with a similar error is directly relevant.

Michael Kay
Saxonica

On 22/10/2011 15:46, dba03 wrote:
Hi,
I use the following code to convert a org.w3c.dom.Document object to xml file.
public void domToInputStream(Document doc, String _strFilePat)
{
TransformerFactory transFactory = TransformerFactory.newInstance(); 
Transformer transFormer = transFactory.newTransformer();
DOMSource domSource = new DOMSource(doc); 
File file = createNewFile(_strFilePath); 
FileOutputStream out = new FileOutputStream(file); 
StreamResult xmlResult = new StreamResult(out); 
transFormer.transform(domSource, xmlResult);
}

But errors:
net.sf.saxon.trans.XPathException: Undeclared namespace in 表:name at net.sf.saxon.dom.DOMSender.outputElement(DOMSender.java:214) at net.sf.saxon.dom.DOMSender.walkNode(DOMSender.java:145) at net.sf.saxon.dom.DOMSender.outputElement(DOMSender.java:228) at net.sf.saxon.dom.DOMSender.walkNode(DOMSender.java:145) at net.sf.saxon.dom.DOMSender.outputElement(DOMSender.java:228) at net.sf.saxon.dom.DOMSender.walkNode(DOMSender.java:145) at net.sf.saxon.dom.DOMSender.outputElement(DOMSender.java:228) at net.sf.saxon.dom.DOMSender.walkNode(DOMSender.java:145) at net.sf.saxon.dom.DOMSender.outputElement(DOMSender.java:228) at net.sf.saxon.dom.DOMSender.walkNode(DOMSender.java:145) at net.sf.saxon.dom.DOMSender.send(DOMSender.java:97) at net.sf.saxon.dom.DOMObjectModel.sendSource(DOMObjectModel.java:112) at net.sf.saxon.event.Sender.send(Sender.java:218) at net.sf.saxon.IdentityTransformer.transform(IdentityTransformer.java:29) at common.TranslatorUtils.domToInputStream(TranslatorUtils.java:347)

 Undeclared namespace in 表:name, is a Chinese character.

If I replace saxon9.jar and saxon9-dom.jar with Xalan.jar, there is no errors.

If I use Jdom(http://www.jdom.org/) to implement the function "domToInputStream", there is no errors, too.
public void domToInputStream(Document doc, String _strFilePat)
{   
DOMBuilder builder = new DOMBuilder();   
XMLOutputter xml = new XMLOutputter();   
String s = xml.outputString(builder.build(document));
 ..........
}

I have read the following email.
http://comments.gmane.org/gmane.text.xml.saxon.help/7090
 "表:name"(Chinese) is not a legal attribute name?
Thanks.






------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help