From 224af751acfc2c83489d39e363ad5b4035b413a0 Mon Sep 17 00:00:00 2001 From: Ryan Gustafson Date: Sat, 27 Sep 2008 06:48:22 +0000 Subject: [PATCH] XMLNode.toString() needs to change node names like '#cdata-section' to remove the '#' characters, which are not value node names for use in XPath query steps. The conversion produces the following element names, which while they may collide with some XML documents, they are easy to use: cdata-section comment document document-fragment text git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6526 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/src/net/sourceforge/pmd/lang/xml/ast/XmlParser.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pmd/src/net/sourceforge/pmd/lang/xml/ast/XmlParser.java b/pmd/src/net/sourceforge/pmd/lang/xml/ast/XmlParser.java index 7a92a92024..dae9fb462f 100644 --- a/pmd/src/net/sourceforge/pmd/lang/xml/ast/XmlParser.java +++ b/pmd/src/net/sourceforge/pmd/lang/xml/ast/XmlParser.java @@ -24,7 +24,6 @@ import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.ast.xpath.Attribute; import org.w3c.dom.Document; -import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.Text; @@ -146,9 +145,9 @@ public class XmlParser { // Delegate method else { if ("toString".equals(method.getName())) { - if (node instanceof Element) { - return ((Element) node).getNodeName(); - } + String s = ((Node) node).getNodeName(); + s = s.replace('#', ''); + return s; } Object result = method.invoke(node, args); return result;