352176 - xml parsing on startElement should be more flexible on using qName or localName

This commit is contained in:
Jan Bartel 2011-07-15 15:21:04 +10:00
parent 295634a369
commit 21f924fa1d
2 changed files with 11 additions and 4 deletions

View File

@ -2,6 +2,7 @@ jetty-7.5.0-SNAPSHOT
+ 351516 Refactored sessions to better support nosql session managers + 351516 Refactored sessions to better support nosql session managers
+ 351576 Do not use deprecated method File.toURL() + 351576 Do not use deprecated method File.toURL()
+ 352046 Need try/catch around features set in XmlParser + 352046 Need try/catch around features set in XmlParser
+ 352176 xml parsing on startElement should be more flexible on using qName or localName
jetty-7.4.4.v20110707 July 7th 2011 jetty-7.4.4.v20110707 July 7th 2011
+ 308851 Converted all jetty-client module tests to JUnit 4 + 308851 Converted all jetty-client module tests to JUnit 4

View File

@ -70,7 +70,6 @@ public class XmlParser
boolean validating_dft = factory.getClass().toString().startsWith("org.apache.xerces."); boolean validating_dft = factory.getClass().toString().startsWith("org.apache.xerces.");
String validating_prop = System.getProperty("org.eclipse.jetty.xml.XmlParser.Validating", validating_dft ? "true" : "false"); String validating_prop = System.getProperty("org.eclipse.jetty.xml.XmlParser.Validating", validating_dft ? "true" : "false");
boolean validating = Boolean.valueOf(validating_prop).booleanValue(); boolean validating = Boolean.valueOf(validating_prop).booleanValue();
setValidating(validating); setValidating(validating);
} }
@ -110,11 +109,12 @@ public class XmlParser
_parser.getXMLReader().setFeature("http://xml.org/sax/features/namespace-prefixes", false); _parser.getXMLReader().setFeature("http://xml.org/sax/features/namespace-prefixes", false);
try try
{ {
_parser.getXMLReader().setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", validating); if (validating)
_parser.getXMLReader().setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", validating);
} }
catch (Exception e) catch (Exception e)
{ {
Log.warn(Log.EXCEPTION, e); Log.warn(e.getMessage());
} }
} }
catch (Exception e) catch (Exception e)
@ -296,7 +296,13 @@ public class XmlParser
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException
{ {
String name = (uri == null || uri.equals("")) ? qName : localName; String name = null;
if (_parser.isNamespaceAware())
name = localName;
if (name == null || "".equals(name))
name = qName;
Node node = new Node(_context, name, attrs); Node node = new Node(_context, name, attrs);