From: <ha...@us...> - 2010-01-24 14:44:51
|
Revision: 12213 http://jmol.svn.sourceforge.net/jmol/?rev=12213&view=rev Author: hansonr Date: 2010-01-24 14:44:45 +0000 (Sun, 24 Jan 2010) Log Message: ----------- xml reader <name .... /> Modified Paths: -------------- trunk/Jmol/src/org/jmol/util/XmlReader.java Modified: trunk/Jmol/src/org/jmol/util/XmlReader.java =================================================================== --- trunk/Jmol/src/org/jmol/util/XmlReader.java 2010-01-24 14:25:07 UTC (rev 12212) +++ trunk/Jmol/src/org/jmol/util/XmlReader.java 2010-01-24 14:44:45 UTC (rev 12213) @@ -87,14 +87,27 @@ return null; } sb.append(line); - while (line.indexOf(closer) < 0) + boolean allowSelfClose = false; + int pt = line.indexOf("/>"); + int pt1 = line.indexOf(">"); + if (pt1 < 0 || pt == pt1 - 1) + allowSelfClose = true; + while (line.indexOf(closer) < 0 && (!allowSelfClose || line.indexOf("/>") < 0)) sb.append(line = br.readLine()); data = sb.toString(); } + return extractTag(data, tag, closer, withTag); + } + + private static String extractTag(String data, String tag, String closer, boolean withTag) { int pt1 = data.indexOf(tag); if (pt1 < 0) return ""; int pt2 = data.indexOf(closer, pt1); + if (pt2 < 0) { + pt2 = data.indexOf("/>", pt1); + closer = "/>"; + } if (pt2 < 0) return ""; if (withTag) { @@ -108,7 +121,7 @@ quoted = !quoted; else if (quoted && ch == '\\') pt1++; - else if (!quoted && ch == '>') + else if (!quoted && (ch == '>' || ch == '/')) break; } if (pt1 >= pt2) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |