Methods Summary |
---|
public void | characters(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)Character content.
if (!isChildFragmentResolved()) {
return;
}
super.characters(text, augs);
|
public void | comment(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)If the comment is a child of a matched element, then pass else return.
if (!isChildFragmentResolved()) {
return;
}
super.comment(text, augs);
|
public void | emptyElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs)An empty element.
if (!resolveXPointer(element, attributes, augs,
XPointerPart.EVENT_ELEMENT_EMPTY)) {
// xml:base and xml:lang processing
if (fFixupBase) {
processXMLBaseAttributes(attributes);
}
if (fFixupLang) {
processXMLLangAttributes(attributes);
}
// no need to restore restoreBaseURI() for xml:base and xml:lang processing
// set the context invalid if the element till an element from the result infoset is included
fNamespaceContext.setContextInvalid();
return;
}
super.emptyElement(element, attributes, augs);
|
public void | endCDATA(org.apache.xerces.xni.Augmentations augs)The end of a CDATA section.
if (!isChildFragmentResolved()) {
return;
}
super.endCDATA(augs);
|
public void | endElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.Augmentations augs)The end of an element.
if (!resolveXPointer(element, null, augs,
XPointerPart.EVENT_ELEMENT_END)) {
// no need to restore restoreBaseURI() for xml:base and xml:lang processing
return;
}
super.endElement(element, augs);
|
public java.util.Vector | getPointerParts()Returns a Vector of XPointerPart objects
return fXPointerParts;
|
public XPointerPart | getXPointerPart()Returns the pointer part used to resolve the document fragment.
return fXPointerPart;
|
public void | ignorableWhitespace(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)Ignorable whitespace. For this method to be called, the document
source must have some way of determining that the text containing
only whitespace characters should be considered ignorable. For
example, the validator can determine if a length of whitespace
characters in the document are ignorable based on the element
content model.
if (!isChildFragmentResolved()) {
return;
}
super.ignorableWhitespace(text, augs);
|
protected void | init()Initializes the XPointer Processor;
fXPointerParts.clear();
fXPointerPart = null;
fFoundMatchingPtrPart = false;
fIsXPointerResolved = false;
//fFixupBase = false;
//fFixupLang = false;
initErrorReporter();
|
protected void | initErrorReporter()Initializes error handling objects
if (fXPointerErrorReporter == null) {
fXPointerErrorReporter = new XMLErrorReporter();
}
if (fErrorHandler == null) {
fErrorHandler = new XPointerErrorHandler();
}
/*
fXPointerErrorReporter.setProperty(Constants.XERCES_PROPERTY_PREFIX
+ Constants.ERROR_HANDLER_PROPERTY, fErrorHandler);
*/
fXPointerErrorReporter.putMessageFormatter(
XPointerMessageFormatter.XPOINTER_DOMAIN,
new XPointerMessageFormatter());
|
public boolean | isChildFragmentResolved()Returns true if the XPointer expression resolves to a non-element child
of the current resource fragment.
boolean resolved = (fXPointerPart != null) ? fXPointerPart
.isChildFragmentResolved() : false;
return resolved;
|
public boolean | isFragmentResolved()Returns true if the Node fragment is resolved.
boolean resolved = (fXPointerPart != null) ? fXPointerPart.isFragmentResolved()
: false;
if (!fIsXPointerResolved) {
fIsXPointerResolved = resolved;
}
return resolved;
|
public boolean | isXPointerResolved()Returns true if the XPointer successfully found a sub-resource .
return fIsXPointerResolved;
|
public void | parseXPointer(java.lang.String xpointer)Parses the XPointer framework expression and delegates scheme specific parsing.
// Initialize
init();
// tokens
final Tokens tokens = new Tokens(fSymbolTable);
// scanner
Scanner scanner = new Scanner(fSymbolTable) {
protected void addToken(Tokens tokens, int token)
throws XNIException {
if (token == Tokens.XPTRTOKEN_OPEN_PAREN
|| token == Tokens.XPTRTOKEN_CLOSE_PAREN
|| token == Tokens.XPTRTOKEN_SCHEMENAME
|| token == Tokens.XPTRTOKEN_SCHEMEDATA
|| token == Tokens.XPTRTOKEN_SHORTHAND) {
super.addToken(tokens, token);
return;
}
reportError("InvalidXPointerToken", new Object[] { tokens
.getTokenString(token) });
}
};
// scan the XPointer expression
int length = xpointer.length();
boolean success = scanner.scanExpr(fSymbolTable, tokens, xpointer, 0,
length);
if (!success)
reportError("InvalidXPointerExpression", new Object[] { xpointer });
while (tokens.hasMore()) {
int token = tokens.nextToken();
switch (token) {
case Tokens.XPTRTOKEN_SHORTHAND: {
// The shortHand name
token = tokens.nextToken();
String shortHandPointerName = tokens.getTokenString(token);
if (shortHandPointerName == null) {
reportError("InvalidXPointerExpression",
new Object[] { xpointer });
}
XPointerPart shortHandPointer = new ShortHandPointer(
fSymbolTable);
shortHandPointer.setSchemeName(shortHandPointerName);
fXPointerParts.add(shortHandPointer);
break;
}
case Tokens.XPTRTOKEN_SCHEMENAME: {
// Retreive the local name and prefix to form the scheme name
token = tokens.nextToken();
String prefix = tokens.getTokenString(token);
token = tokens.nextToken();
String localName = tokens.getTokenString(token);
String schemeName = prefix + localName;
// The next character should be an open parenthesis
int openParenCount = 0;
int closeParenCount = 0;
token = tokens.nextToken();
String openParen = tokens.getTokenString(token);
if (openParen != "XPTRTOKEN_OPEN_PAREN") {
// can not have more than one ShortHand Pointer
if (token == Tokens.XPTRTOKEN_SHORTHAND) {
reportError("MultipleShortHandPointers",
new Object[] { xpointer });
} else {
reportError("InvalidXPointerExpression",
new Object[] { xpointer });
}
}
openParenCount++;
// followed by zero or more ( and the schemeData
String schemeData = null;
while (tokens.hasMore()) {
token = tokens.nextToken();
schemeData = tokens.getTokenString(token);
if (schemeData != "XPTRTOKEN_OPEN_PAREN") {
break;
}
openParenCount++;
}
token = tokens.nextToken();
schemeData = tokens.getTokenString(token);
// followed by the same number of )
token = tokens.nextToken();
String closeParen = tokens.getTokenString(token);
if (closeParen != "XPTRTOKEN_CLOSE_PAREN") {
reportError("SchemeDataNotFollowedByCloseParenthesis",
new Object[] { xpointer });
}
closeParenCount++;
while (tokens.hasMore()) {
if (tokens.getTokenString(tokens.peekToken()) != "XPTRTOKEN_OPEN_PAREN") {
break;
}
closeParenCount++;
}
// check if the number of open parenthesis are equal to the number of close parenthesis
if (openParenCount != closeParenCount) {
reportError("UnbalancedParenthesisInXPointerExpression",
new Object[] { xpointer,
new Integer(openParenCount),
new Integer(closeParenCount) });
}
// Perform scheme specific parsing of the pointer part
if (schemeName.equals(ELEMENT_SCHEME_NAME)) {
XPointerPart elementSchemePointer = new ElementSchemePointer(
fSymbolTable, fErrorReporter);
elementSchemePointer.setSchemeName(schemeName);
elementSchemePointer.setSchemeData(schemeData);
// If an exception occurs while parsing the element() scheme expression
// ignore it and move on to the next pointer part
try {
elementSchemePointer.parseXPointer(schemeData);
fXPointerParts.add(elementSchemePointer);
} catch (XNIException e) {
// Re-throw the XPointer element() scheme syntax error.
throw new XNIException (e);
}
} else {
// ????
reportWarning("SchemeUnsupported",
new Object[] { schemeName });
}
break;
}
default:
reportError("InvalidXPointerExpression",
new Object[] { xpointer });
}
}
|
public void | processingInstruction(java.lang.String target, org.apache.xerces.xni.XMLString data, org.apache.xerces.xni.Augmentations augs)A processing instruction. Processing instructions consist of a
target name and, optionally, text data. The data is only meaningful
to the application.
Typically, a processing instruction's data will contain a series
of pseudo-attributes. These pseudo-attributes follow the form of
element attributes but are not parsed or presented
to the application as anything other than text. The application is
responsible for parsing the data.
if (!isChildFragmentResolved()) {
return;
}
super.processingInstruction(target, data, augs);
|
private void | reportError(java.lang.String key, java.lang.Object[] arguments)Reports XPointer Errors
/*
fXPointerErrorReporter.reportError(
XPointerMessageFormatter.XPOINTER_DOMAIN, key, arguments,
XMLErrorReporter.SEVERITY_ERROR);
*/
throw new XNIException((fErrorReporter
.getMessageFormatter(XPointerMessageFormatter.XPOINTER_DOMAIN))
.formatMessage(fErrorReporter.getLocale(), key, arguments));
|
private void | reportWarning(java.lang.String key, java.lang.Object[] arguments)Reports XPointer Warnings
fXPointerErrorReporter.reportError(
XPointerMessageFormatter.XPOINTER_DOMAIN, key, arguments,
XMLErrorReporter.SEVERITY_WARNING);
|
public boolean | resolveXPointer(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs, int event)
boolean resolved = false;
// The result of the first pointer part whose evaluation identifies
// one or more subresources is reported by the XPointer processor as the
// result of the pointer as a whole, and evaluation stops.
// In our implementation, typically the first xpointer scheme that
// matches an element is the document is considered.
// If the pointer part resolved then use it, else search for the fragment
// using next pointer part from lef-right.
if (!fFoundMatchingPtrPart) {
// for each element, attempt to resolve it against each pointer part
// in the XPointer expression until a matching element is found.
for (int i = 0; i < fXPointerParts.size(); i++) {
fXPointerPart = (XPointerPart) fXPointerParts.get(i);
if (fXPointerPart.resolveXPointer(element, attributes, augs,
event)) {
fFoundMatchingPtrPart = true;
resolved = true;
}
}
} else {
if (fXPointerPart.resolveXPointer(element, attributes, augs, event)) {
resolved = true;
}
}
if (!fIsXPointerResolved) {
fIsXPointerResolved = resolved;
}
return resolved;
|
public void | setDocumentHandler(org.apache.xerces.xni.XMLDocumentHandler handler)
fDocumentHandler = handler;
|
public void | setProperty(java.lang.String propertyId, java.lang.Object value)
Sets the value of a property. This method is called by the component
manager any time after reset when a property changes value.
Note: Components should silently ignore properties
that do not affect the operation of the component.
// Error reporter
if (propertyId == Constants.XERCES_PROPERTY_PREFIX
+ Constants.ERROR_REPORTER_PROPERTY) {
if (value != null) {
fXPointerErrorReporter = (XMLErrorReporter) value;
} else {
fXPointerErrorReporter = null;
}
}
// Error handler
if (propertyId == Constants.XERCES_PROPERTY_PREFIX
+ Constants.ERROR_HANDLER_PROPERTY) {
if (value != null) {
fErrorHandler = (XMLErrorHandler) value;
} else {
fErrorHandler = null;
}
}
// xml:lang
if (propertyId == Constants.XERCES_FEATURE_PREFIX
+ Constants.XINCLUDE_FIXUP_LANGUAGE_FEATURE) {
if (value != null) {
fFixupLang = ((Boolean)value).booleanValue();
} else {
fFixupLang = false;
}
}
// xml:base
if (propertyId == Constants.XERCES_FEATURE_PREFIX
+ Constants.XINCLUDE_FIXUP_BASE_URIS_FEATURE) {
if (value != null) {
fFixupBase = ((Boolean)value).booleanValue();
} else {
fFixupBase = false;
}
}
//
if (propertyId == Constants.XERCES_PROPERTY_PREFIX
+ Constants.NAMESPACE_CONTEXT_PROPERTY) {
fNamespaceContext = (XIncludeNamespaceSupport) value;
}
super.setProperty(propertyId, value);
|
public void | startCDATA(org.apache.xerces.xni.Augmentations augs)The start of a CDATA section.
if (!isChildFragmentResolved()) {
return;
}
super.startCDATA(augs);
|
public void | startElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs)The start of an element.
if (!resolveXPointer(element, attributes, augs,
XPointerPart.EVENT_ELEMENT_START)) {
// xml:base and xml:lang processing
if (fFixupBase) {
processXMLBaseAttributes(attributes);
}
if (fFixupLang) {
processXMLLangAttributes(attributes);
}
// set the context invalid if the element till an element from the result infoset is included
fNamespaceContext.setContextInvalid();
return;
}
super.startElement(element, attributes, augs);
|