XML parsing error: A node test that matches either NCName:* or QName was expected.

Denis Bredelet <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
What does this error mean?

This is my template:

[#ftl]
Parsing HelloWorld.xml

[#recurse doc]


[#macro @element]
${.node.@@start_tag}
[#if .node?children?size > 0]  (I tried to add this to get rid of the error)
[#recurse]
${.node.@@close_tag}
[/#if]
[/#macro]


[#macro @text]
[/#macro]


The maximum depth of my XML is no more than 12. Most nodes have just a single attribute, no text. Note that the error is on the close tag instruction?


$ java HelloWorld
22-Jul-2008 23:43:36 freemarker.log.JDK14LoggerFactory$JDK14Logger error
SEVERE: 

javax.xml.transform.TransformerException: A node test that matches either NCName:* or QName was expected.
The problematic instruction:
----------
==> ${.node.@@close_tag} [on line 11, column 1 in template.ftl]
----------

Java backtrace for programmers:
----------
freemarker.template.TemplateModelException: javax.xml.transform.TransformerException: A node test that matches either NCName:* or QName was expected.
	at freemarker.ext.dom.XalanXPathSupport.executeQuery(XalanXPathSupport.java:137)
	at freemarker.ext.dom.NodeModel.get(NodeModel.java:279)
	at freemarker.ext.dom.ElementModel.get(ElementModel.java:130)
	at freemarker.core.Dot._getAsTemplateModel(Dot.java:76)
	at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
	at freemarker.core.Expression.getStringValue(Expression.java:93)
	at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.Macro$Context.runMacro(Macro.java:164)
	at freemarker.core.Environment.visit(Environment.java:601)
	at freemarker.core.Environment.visit(Environment.java:451)
	at freemarker.core.Environment.recurse(Environment.java:642)
	at freemarker.core.RecurseNode.accept(RecurseNode.java:94)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.Macro$Context.runMacro(Macro.java:164)
	at freemarker.core.Environment.visit(Environment.java:601)
	at freemarker.core.Environment.visit(Environment.java:451)
	at freemarker.core.Environment.recurse(Environment.java:642)
	at freemarker.core.RecurseNode.accept(RecurseNode.java:94)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.Macro$Context.runMacro(Macro.java:164)
	at freemarker.core.Environment.visit(Environment.java:601)
	at freemarker.core.Environment.visit(Environment.java:451)
	at freemarker.core.Environment.recurse(Environment.java:642)
	at freemarker.core.RecurseNode.accept(RecurseNode.java:94)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.Macro$Context.runMacro(Macro.java:164)
	at freemarker.core.Environment.visit(Environment.java:601)
	at freemarker.core.Environment.visit(Environment.java:451)
	at freemarker.core.Environment.recurse(Environment.java:642)
	at freemarker.core.RecurseNode.accept(RecurseNode.java:94)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.Macro$Context.runMacro(Macro.java:164)
	at freemarker.core.Environment.visit(Environment.java:601)
	at freemarker.core.Environment.visit(Environment.java:451)
	at freemarker.core.Environment.recurse(Environment.java:642)
	at freemarker.core.RecurseNode.accept(RecurseNode.java:94)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.Macro$Context.runMacro(Macro.java:164)
	at freemarker.core.Environment.visit(Environment.java:601)
	at freemarker.core.Environment.visit(Environment.java:451)
	at freemarker.core.Environment.recurse(Environment.java:642)
	at freemarker.core.RecurseNode.accept(RecurseNode.java:94)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.Macro$Context.runMacro(Macro.java:164)
	at freemarker.core.Environment.visit(Environment.java:601)
	at freemarker.core.Environment.visit(Environment.java:451)
	at freemarker.core.Environment.recurse(Environment.java:642)
	at freemarker.core.RecurseNode.accept(RecurseNode.java:94)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.Environment.process(Environment.java:188)
	at freemarker.template.Template.process(Template.java:237)
	at HelloWorld.freemarkerDo(HelloWorld.java:32)
	at HelloWorld.main(HelloWorld.java:18)
Caused by: javax.xml.transform.TransformerException: A node test that matches either NCName:* or QName was expected.
	at org.apache.xpath.compiler.XPathParser.error(XPathParser.java:649)
	at org.apache.xpath.compiler.XPathParser.NodeTest(XPathParser.java:1910)
	at org.apache.xpath.compiler.XPathParser.Basis(XPathParser.java:1773)
	at org.apache.xpath.compiler.XPathParser.Step(XPathParser.java:1709)
	at org.apache.xpath.compiler.XPathParser.RelativeLocationPath(XPathParser.java:1613)
	at org.apache.xpath.compiler.XPathParser.LocationPath(XPathParser.java:1584)
	at org.apache.xpath.compiler.XPathParser.PathExpr(XPathParser.java:1306)
	at org.apache.xpath.compiler.XPathParser.UnionExpr(XPathParser.java:1225)
	at org.apache.xpath.compiler.XPathParser.UnaryExpr(XPathParser.java:1131)
	at org.apache.xpath.compiler.XPathParser.MultiplicativeExpr(XPathParser.java:1052)
	at org.apache.xpath.compiler.XPathParser.AdditiveExpr(XPathParser.java:994)
	at org.apache.xpath.compiler.XPathParser.RelationalExpr(XPathParser.java:919)
	at org.apache.xpath.compiler.XPathParser.EqualityExpr(XPathParser.java:859)
	at org.apache.xpath.compiler.XPathParser.AndExpr(XPathParser.java:823)
	at org.apache.xpath.compiler.XPathParser.OrExpr(XPathParser.java:796)
	at org.apache.xpath.compiler.XPathParser.Expr(XPathParser.java:779)
	at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:172)
	at org.apache.xpath.XPath.<init>(XPath.java:202)
	at freemarker.ext.dom.XalanXPathSupport.executeQuery(XalanXPathSupport.java:107)
	... 97 more



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.