private void doTestXmlId(boolean xmlidEnabled,
boolean nsAware, boolean coal)
throws XMLStreamException
{
XMLStreamReader2 sr = getReader(XML_WITH_XMLID, xmlidEnabled, nsAware, coal);
final String xmlidType = xmlidEnabled ? "ID" : "CDATA";
// root:
assertTokenType(START_ELEMENT, sr.next());
assertEquals(1, sr.getAttributeCount());
assertEquals("id", sr.getAttributeLocalName(0));
assertEquals("CDATA", sr.getAttributeType(0));
assertEquals(-1, sr.getAttributeInfo().getIdAttributeIndex());
// leaf#1:
assertTokenType(START_ELEMENT, sr.next());
assertEquals(1, sr.getAttributeCount());
assertEquals("abc", sr.getAttributeValue(0));
if (xmlidEnabled) {
assertEquals(0, sr.getAttributeInfo().getIdAttributeIndex());
} else {
assertEquals(-1, sr.getAttributeInfo().getIdAttributeIndex());
}
assertEquals(xmlidType, sr.getAttributeType(0));
assertTokenType(END_ELEMENT, sr.next());
// leaf#2:
assertTokenType(START_ELEMENT, sr.next());
assertEquals(1, sr.getAttributeCount());
assertEquals("foobar", sr.getAttributeValue(0));
assertEquals("id", sr.getAttributeLocalName(0));
assertEquals(-1, sr.getAttributeInfo().getIdAttributeIndex());
assertEquals("CDATA", sr.getAttributeType(0));
assertTokenType(END_ELEMENT, sr.next());
// leaf#3:
assertTokenType(START_ELEMENT, sr.next());
assertEquals(1, sr.getAttributeCount());
assertEquals(xmlidType, sr.getAttributeType(0));
if (xmlidEnabled) {
assertEquals(0, sr.getAttributeInfo().getIdAttributeIndex());
} else {
assertEquals(-1, sr.getAttributeInfo().getIdAttributeIndex());
}
// also, should be normalized:
if (xmlidEnabled) {
assertEquals("_otherId", sr.getAttributeValue(0));
} else {
assertEquals(" _otherId ", sr.getAttributeValue(0));
}
assertTokenType(END_ELEMENT, sr.next());
sr.close();
}