* @throws XMLStreamException
*/
private String processXopInclude() throws XMLStreamException {
if (super.getAttributeCount() != 1 ||
!super.getAttributeLocalName(0).equals(XOPConstants.HREF)) {
throw new XMLStreamException("Expected xop:Include element information item with " +
"a (single) href attribute");
}
String href = super.getAttributeValue(0);
if(log.isDebugEnabled()){
log.debug("processXopInclude - found href : " + href);
}
if (!href.startsWith("cid:")) {
throw new XMLStreamException("Expected href attribute containing a URL in the " +
"cid scheme");
}
String contentID;
try {
// URIs should always be decoded using UTF-8. On the other hand, since non ASCII
// characters are not allowed in content IDs, we can simply decode using ASCII
// (which is a subset of UTF-8)
contentID = URLDecoder.decode(href.substring(4), "ascii");
if(log.isDebugEnabled()){
log.debug("processXopInclude - decoded contentID : " + contentID);
}
} catch (UnsupportedEncodingException ex) {
// We should never get here
throw new XMLStreamException(ex);
}
if (super.next() != END_ELEMENT) {
throw new XMLStreamException(
"Expected xop:Include element information item to be empty");
}
// Also consume the END_ELEMENT event of the xop:Include element. There are
// two reasons for this:
// - It allows us to validate that the message conforms to the XOP specs.
// - It makes it easier to implement the getNamespaceContext method.
if (super.next() != END_ELEMENT) {
throw new XMLStreamException(SOLE_CHILD_MSG);
}
if (log.isDebugEnabled()) {
log.debug("Encountered xop:Include for content ID '" + contentID + "'");
}
return contentID;