ArrayList<String> nodeNames = new ArrayList<String>();
ArrayList<String> xmlnsNames = new ArrayList<String>();
ArrayList<String> xmlnsUris = new ArrayList<String>();
namespaceBindings = new ArrayList<NamespaceBinding>();
RegExp quotesPattern = RegExp.compile("(?:\"(.|\n)*?\"|\'(.|\n)*?\'|[^\'\"]+|['\"])", "gm"); // g=global: = all-matches m=multiline
MatchResult m = quotesPattern.exec(value);
int i = 0;
String nonQ = "";
boolean awaitingXmlnsUri = false;
while (quotesPattern.getLastIndex() > 0) {
if (i % 2 == 0) {
nonQ = m.getGroup(0); // not in quotes - so check
StringBuffer sb = new StringBuffer();
boolean endOfTag = false;
boolean isName = !(i == 0);// first part is not a name: e.g. \r\n<H1 style="
int start = 0;
if (i == 0) {
start = nonQ.indexOf('<') + 1;
}
for (int x = start; x < nonQ.length(); x++) {
int[] offsetChar = skipWhitespace(x, nonQ, false);
int offset = offsetChar[0];
if(offset > 0 && !(isName)) {
// no whitespace allow in an unquoted value, so we're back on a name
isName = true;
}
char ch = (char)offsetChar[1];
if (ch == '\0') break;
if (ch == '=') {
// part after the '=' is the value, until next whitespace
isName = false;
String attName = sb.toString();
if (attName.startsWith("xmlns")) {
xmlnsNames.add(attName);
awaitingXmlnsUri = true;
} else if(attName.length() != 0) {
nodeNames.add(attName);
awaitingXmlnsUri = false;
}
sb = new StringBuffer();
continue;
} else if (ch == '>') {
endOfTag = true;
break;
}
if (isName) {
sb.append(ch);
}
x += offset;
} // end for
if (endOfTag) {
break;
}
} else if (awaitingXmlnsUri) {// ends if i % 2
xmlnsUris.add(m.getGroup(0));
}
i++;
m = quotesPattern.exec(value);
} // end while
HTMLAttributeNode[] nodeArray = new HTMLAttributeNode[nodeNames.size()];
for (int y = 0; y < nodeNames.size(); y++) {
String name = nodeNames.get(y);