本文整理汇总了Java中org.apache.xerces.xni.NamespaceContext类的典型用法代码示例。如果您正苦于以下问题:Java NamespaceContext类的具体用法?Java NamespaceContext怎么用?Java NamespaceContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NamespaceContext类属于org.apache.xerces.xni包,在下文中一共展示了NamespaceContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setProperty
import org.apache.xerces.xni.NamespaceContext; //导入依赖的package包/类
/**
* Sets the value of a property. This method is called by the component
* manager any time after reset when a property changes value.
* <p>
* <strong>Note:</strong> Components should silently ignore properties
* that do not affect the operation of the component.
*
* @param propertyId The property identifier.
* @param value The value of the property.
*
* @throws SAXNotRecognizedException The component should not throw
* this exception.
* @throws SAXNotSupportedException The component should not throw
* this exception.
*/
public void setProperty(String propertyId, Object value)
throws XMLConfigurationException {
super.setProperty(propertyId, value);
// Xerces properties
if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();
if (suffixLength == Constants.DTD_SCANNER_PROPERTY.length() &&
propertyId.endsWith(Constants.DTD_SCANNER_PROPERTY)) {
fDTDScanner = (XMLDTDScanner)value;
}
if (suffixLength == Constants.NAMESPACE_CONTEXT_PROPERTY.length() &&
propertyId.endsWith(Constants.NAMESPACE_CONTEXT_PROPERTY)) {
if (value != null) {
fNamespaceContext = (NamespaceContext)value;
}
}
return;
}
}
示例2: addNamespaceDecl
import org.apache.xerces.xni.NamespaceContext; //导入依赖的package包/类
/**
* Adds a namespace attribute or replaces the value of existing namespace
* attribute with the given prefix and value for URI.
* In case prefix is empty will add/update default namespace declaration.
*
* @param prefix
* @param uri
* @exception IOException
*/
protected final void addNamespaceDecl(String prefix, String uri, ElementImpl element){
if (DEBUG) {
System.out.println("[ns-fixup] addNamespaceDecl ["+prefix+"]");
}
if (prefix == XMLSymbols.EMPTY_STRING) {
if (DEBUG) {
System.out.println("=>add xmlns=\""+uri+"\" declaration");
}
element.setAttributeNS(NamespaceContext.XMLNS_URI, XMLSymbols.PREFIX_XMLNS, uri);
} else {
if (DEBUG) {
System.out.println("=>add xmlns:"+prefix+"=\""+uri+"\" declaration");
}
element.setAttributeNS(NamespaceContext.XMLNS_URI, "xmlns:"+prefix, uri);
}
}
示例3: reset
import org.apache.xerces.xni.NamespaceContext; //导入依赖的package包/类
/**
* @see org.apache.xerces.xni.NamespaceContext#reset()
*/
public void reset() {
// reset namespace and context info
fNamespaceSize = 0;
fCurrentContext = 0;
fContext[fCurrentContext] = fNamespaceSize;
// bind "xml" prefix to the XML uri
fNamespace[fNamespaceSize++] = XMLSymbols.PREFIX_XML;
fNamespace[fNamespaceSize++] = NamespaceContext.XML_URI;
// bind "xmlns" prefix to the XMLNS uri
fNamespace[fNamespaceSize++] = XMLSymbols.PREFIX_XMLNS;
fNamespace[fNamespaceSize++] = NamespaceContext.XMLNS_URI;
++fCurrentContext;
}
示例4: startDocument
import org.apache.xerces.xni.NamespaceContext; //导入依赖的package包/类
public void startDocument(XMLLocator locator, String encoding,
NamespaceContext namespaceContext, Augmentations augs)
throws XNIException {
fErrorReporter = (XMLErrorReporter)config.getProperty(ERROR_REPORTER);
fGenerateSyntheticAnnotation = config.getFeature(GENERATE_SYNTHETIC_ANNOTATION);
fHasNonSchemaAttributes.clear();
fSawAnnotation.clear();
schemaDOM = new SchemaDOM();
fCurrentAnnotationElement = null;
fAnnotationDepth = -1;
fInnerAnnotationDepth = -1;
fDepth = -1;
fLocator = locator;
fNamespaceContext = namespaceContext;
schemaDOM.setDocumentURI(locator.getExpandedSystemId());
}
示例5: XPath
import org.apache.xerces.xni.NamespaceContext; //导入依赖的package包/类
/** Constructs a field XPath expression. */
public XPath(String xpath,
SymbolTable symbolTable,
NamespaceContext context) throws XPathException {
super(fixupXPath(xpath), symbolTable, context);
// verify that only one attribute is selected per branch
for (int i=0;i<fLocationPaths.length;i++) {
for(int j=0; j<fLocationPaths[i].steps.length; j++) {
org.apache.xerces.impl.xpath.XPath.Axis axis =
fLocationPaths[i].steps[j].axis;
if (axis.type == XPath.Axis.ATTRIBUTE &&
(j < fLocationPaths[i].steps.length-1)) {
throw new XPathException("c-fields-xpaths");
}
}
}
}
示例6: getPrefix
import org.apache.xerces.xni.NamespaceContext; //导入依赖的package包/类
public String getPrefix(String uri, int start, int end) {
// this saves us from having a copy of each of these in fNamespace for each scope
if (uri == NamespaceContext.XML_URI) {
return XMLSymbols.PREFIX_XML;
}
if (uri == NamespaceContext.XMLNS_URI) {
return XMLSymbols.PREFIX_XMLNS;
}
// find uri in current context
for (int i = start; i > end; i -= 2) {
if (fNamespace[i - 1] == uri) {
if (getURI(fNamespace[i - 2]) == uri)
return fNamespace[i - 2];
}
}
// uri not found
return null;
}
示例7: getURI
import org.apache.xerces.xni.NamespaceContext; //导入依赖的package包/类
public String getURI(String prefix, int start, int end) {
// this saves us from having a copy of each of these in fNamespace for each scope
if (prefix == XMLSymbols.PREFIX_XML) {
return NamespaceContext.XML_URI;
}
if (prefix == XMLSymbols.PREFIX_XMLNS) {
return NamespaceContext.XMLNS_URI;
}
// find prefix in current context
for (int i = start; i > end; i -= 2) {
if (fNamespace[i - 2] == prefix) {
return fNamespace[i - 1];
}
}
// prefix not found
return null;
}
示例8: processXMLBaseAttributes
import org.apache.xerces.xni.NamespaceContext; //导入依赖的package包/类
/**
* Search for a xml:base attribute, and if one is found, put the new base URI into
* effect.
*/
protected void processXMLBaseAttributes(XMLAttributes attributes) {
String baseURIValue =
attributes.getValue(NamespaceContext.XML_URI, "base");
if (baseURIValue != null) {
try {
String expandedValue =
XMLEntityManager.expandSystemId(
baseURIValue,
fCurrentBaseURI.getExpandedSystemId(),
false);
fCurrentBaseURI.setLiteralSystemId(baseURIValue);
fCurrentBaseURI.setBaseSystemId(
fCurrentBaseURI.getExpandedSystemId());
fCurrentBaseURI.setExpandedSystemId(expandedValue);
// push the new values on the stack
saveBaseURI();
}
catch (MalformedURIException e) {
// REVISIT: throw error here
}
}
}
示例9: processInScopeNamespaces
import org.apache.xerces.xni.NamespaceContext; //导入依赖的package包/类
/**
* Write an unordered set of namespace information items, one for each of the
* namespaces in effect for this element. This set always contains an item
* with the prefix xml which is implicitly bound to the namespace name
* http://www.w3.org/XML/1998/namespace. It does not contain an item with the
* prefix xmlns (used for declaring namespaces), since an application can
* never encounter an element or attribute with that prefix. The set will
* include namespace items corresponding to all of the members of
* [namespace attributes], except for any representing a declaration of the
* form xmlns="", which does not declare a namespace but rather undeclares
* the default namespace
*/
private void processInScopeNamespaces() {
sendIndentedElement("inScopeNamespaces");
sendIndentedElement("namespace");
// print 'xml' binding
sendElementEvent("prefix", "xml");
sendElementEvent("namespaceName", NamespaceContext.XML_URI);
sendUnIndentedElement("namespace");
Enumeration prefixes = fNamespaceContext.getAllPrefixes();
while (prefixes.hasMoreElements()) {
sendIndentedElement("namespace");
String prefix = (String)prefixes.nextElement();
String uri = fNamespaceContext.getURI(prefix);
sendElementEvent("prefix", prefix);
sendElementEvent("namespaceName", uri);
sendUnIndentedElement("namespace");
}
sendUnIndentedElement("inScopeNamespaces");
}
示例10: startDocument
import org.apache.xerces.xni.NamespaceContext; //导入依赖的package包/类
public void startDocument(XMLLocator locator, String encoding,
NamespaceContext namespaceContext, Augmentations augs) throws XNIException {
super.startDocument(locator, encoding, namespaceContext, augs);
this.locator = locator;
Node node = null ;
try {
node = (Node) this.getProperty( "http://apache.org/xml/properties/dom/current-element-node" );
}
catch( org.xml.sax.SAXException ex )
{
System.err.println( "except" + ex );;
}
if( node != null )
node.setUserData( "startLine", String.valueOf( locator.getLineNumber() ), null ); // Save location String into node
}
示例11: startDocument
import org.apache.xerces.xni.NamespaceContext; //导入依赖的package包/类
/**
* Override the document start to record whether HTML, HEAD or BODY have been seen
*/
@Override
public void startDocument(XMLLocator locator, String encoding,
NamespaceContext nscontext, Augmentations augs)
throws XNIException {
super.startDocument(locator, encoding, nscontext, augs);
for (int i = fElementStack.top - 1; i >= 0; i--) {
fSeenAnything = true;
if (fElementStack.data[i].element.code == HTMLElements.HTML) {
fSeenRootElement = true;
}
if (fElementStack.data[i].element.code == HTMLElements.HEAD) {
fSeenHeadElement = true;
}
if (fElementStack.data[i].element.code == HTMLElements.BODY) {
fSeenBodyElement = true;
}
}
}
示例12: startDocument
import org.apache.xerces.xni.NamespaceContext; //导入依赖的package包/类
/** Start document. */
public void startDocument(XMLLocator locator, String encoding,
NamespaceContext nscontext, Augmentations augs)
throws XNIException {
// reset state
fElementStack.top = 0;
if (fragmentContextStack_ != null) {
fragmentContextStackSize_ = fragmentContextStack_.length;
for (int i=0; i<fragmentContextStack_.length; ++i) {
final QName name = fragmentContextStack_[i];
final Element elt = HTMLElements.getElement(name.localpart);
fElementStack.push(new Info(elt, name));
}
}
else {
fragmentContextStackSize_ = 0;
}
fSeenAnything = false;
fSeenDoctype = false;
fSeenRootElement = false;
fSeenRootElementEnd = false;
fSeenHeadElement = false;
fSeenBodyElement = false;
// pass on event
if (fDocumentHandler != null) {
XercesBridge.getInstance().XMLDocumentHandler_startDocument(fDocumentHandler, locator, encoding, nscontext, augs);
}
}
示例13: startDocument
import org.apache.xerces.xni.NamespaceContext; //导入依赖的package包/类
@Override
public void startDocument(XMLLocator arg0, String arg1,
NamespaceContext arg2, Augmentations arg3) throws XNIException {
if(DEBUG_UNUSED) {
Out.println("startDocument");
}
}
示例14: startDocument
import org.apache.xerces.xni.NamespaceContext; //导入依赖的package包/类
/**
* The start of the document.
*
* @param locator The document locator, or null if the document
* location cannot be reported during the parsing
* of this document. However, it is <em>strongly</em>
* recommended that a locator be supplied that can
* at least report the system identifier of the
* document.
* @param encoding The auto-detected IANA encoding name of the entity
* stream. This value will be null in those situations
* where the entity encoding is not auto-detected (e.g.
* internal entities or a document entity that is
* parsed from a java.io.Reader).
* @param namespaceContext
* The namespace context in effect at the
* start of this document.
* This object represents the current context.
* Implementors of this class are responsible
* for copying the namespace bindings from the
* the current context (and its parent contexts)
* if that information is important.
* @param augs Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void startDocument(XMLLocator locator, String encoding,
NamespaceContext namespaceContext, Augmentations augs)
throws XNIException {
fNamespaceContext = namespaceContext;
try {
// SAX1
if (fDocumentHandler != null) {
if (locator != null) {
fDocumentHandler.setDocumentLocator(new LocatorProxy(locator));
}
fDocumentHandler.startDocument();
}
// SAX2
if (fContentHandler != null) {
if (locator != null) {
fContentHandler.setDocumentLocator(new LocatorProxy(locator));
}
fContentHandler.startDocument();
}
}
catch (SAXException e) {
throw new XNIException(e);
}
}
示例15: startDocument
import org.apache.xerces.xni.NamespaceContext; //导入依赖的package包/类
/**
* The start of the document.
*
* @param locator The document locator, or null if the document
* location cannot be reported during the parsing
* of this document. However, it is <em>strongly</em>
* recommended that a locator be supplied that can
* at least report the system identifier of the
* document.
* @param encoding The auto-detected IANA encoding name of the entity
* stream. This value will be null in those situations
* where the entity encoding is not auto-detected (e.g.
* internal entities or a document entity that is
* parsed from a java.io.Reader).
* @param namespaceContext
* The namespace context in effect at the
* start of this document.
* This object represents the current context.
* Implementors of this class are responsible
* for copying the namespace bindings from the
* the current context (and its parent contexts)
* if that information is important.
* @param augs Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void startDocument(XMLLocator locator, String encoding,
NamespaceContext namespaceContext, Augmentations augs)
throws XNIException {
fNamespaceContext = namespaceContext;
try {
// SAX1
if (fDocumentHandler != null) {
if (locator != null) {
fDocumentHandler.setDocumentLocator(new LocatorProxy(locator));
}
// The application may have set the DocumentHandler to null
// within setDocumentLocator() so we need to check again.
if (fDocumentHandler != null) {
fDocumentHandler.startDocument();
}
}
// SAX2
if (fContentHandler != null) {
if (locator != null) {
fContentHandler.setDocumentLocator(new LocatorProxy(locator));
}
// The application may have set the ContentHandler to null
// within setDocumentLocator() so we need to check again.
if (fContentHandler != null) {
fContentHandler.startDocument();
}
}
}
catch (SAXException e) {
throw new XNIException(e);
}
}