Java Code Examples for com.sun.org.apache.xml.internal.res.XMLMessages#createXMLMessage()
The following examples show how to use
com.sun.org.apache.xml.internal.res.XMLMessages#createXMLMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SAX2DTM2.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Returns a deep copy of this iterator. The cloned iterator is not reset. * * @return a deep copy of this iterator. */ public DTMAxisIterator cloneIterator() { _isRestartable = false; // must set to false for any clone try { final AncestorIterator clone = (AncestorIterator) super.clone(); clone._startNode = _startNode; // return clone.reset(); return clone; } catch (CloneNotSupportedException e) { throw new DTMException(XMLMessages.createXMLMessage(XMLErrorResources.ER_ITERATOR_CLONE_NOT_SUPPORTED, null)); //"Iterator clone not supported."); } }
Example 2
Source File: URI.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * Set the port for this URI. -1 is used to indicate that the port is * not specified, otherwise valid port numbers are between 0 and 65535. * If a valid port number is passed in and the host field is null, * an exception is thrown. * * @param p_port the port number for this URI * * @throws MalformedURIException if p_port is not -1 and not a * valid port number */ public void setPort(int p_port) throws MalformedURIException { if (p_port >= 0 && p_port <= 65535) { if (m_host == null) { throw new MalformedURIException( XMLMessages.createXMLMessage(XMLErrorResources.ER_PORT_WHEN_HOST_NULL, null)); //"Port cannot be set when host is null!"); } } else if (p_port != -1) { throw new MalformedURIException(XMLMessages.createXMLMessage(XMLErrorResources.ER_INVALID_PORT, null)); //"Invalid port number!"); } m_port = p_port; }
Example 3
Source File: URI.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Set the port for this URI. -1 is used to indicate that the port is * not specified, otherwise valid port numbers are between 0 and 65535. * If a valid port number is passed in and the host field is null, * an exception is thrown. * * @param p_port the port number for this URI * * @throws MalformedURIException if p_port is not -1 and not a * valid port number */ public void setPort(int p_port) throws MalformedURIException { if (p_port >= 0 && p_port <= 65535) { if (m_host == null) { throw new MalformedURIException( XMLMessages.createXMLMessage(XMLErrorResources.ER_PORT_WHEN_HOST_NULL, null)); //"Port cannot be set when host is null!"); } } else if (p_port != -1) { throw new MalformedURIException(XMLMessages.createXMLMessage(XMLErrorResources.ER_INVALID_PORT, null)); //"Invalid port number!"); } m_port = p_port; }
Example 4
Source File: IncrementalSAXSource_Xerces.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** startParse() is a simple API which tells the IncrementalSAXSource * to begin reading a document. * * @throws SAXException is parse thread is already in progress * or parsing can not be started. * */ public void startParse(InputSource source) throws SAXException { if (fIncrementalParser==null) throw new SAXException(XMLMessages.createXMLMessage(XMLErrorResources.ER_STARTPARSE_NEEDS_SAXPARSER, null)); //"startParse needs a non-null SAXParser."); if (fParseInProgress) throw new SAXException(XMLMessages.createXMLMessage(XMLErrorResources.ER_STARTPARSE_WHILE_PARSING, null)); //"startParse may not be called while parsing."); boolean ok=false; try { ok = parseSomeSetup(source); } catch(Exception ex) { throw new SAXException(ex); } if(!ok) throw new SAXException(XMLMessages.createXMLMessage(XMLErrorResources.ER_COULD_NOT_INIT_PARSER, null)); //"could not initialize parser with"); }
Example 5
Source File: URI.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Set the fragment for this URI. A non-null value is valid only * if this is a URI conforming to the generic URI syntax and * the path value is not null. * * @param p_fragment the fragment for this URI * * @throws MalformedURIException if p_fragment is not null and this * URI does not conform to the generic * URI syntax or if the path is null */ public void setFragment(String p_fragment) throws MalformedURIException { if (p_fragment == null) { m_fragment = null; } else if (!isGenericURI()) { throw new MalformedURIException( XMLMessages.createXMLMessage(XMLErrorResources.ER_FRAG_FOR_GENERIC_URI, null)); //"Fragment can only be set for a generic URI!"); } else if (getPath() == null) { throw new MalformedURIException( XMLMessages.createXMLMessage(XMLErrorResources.ER_FRAG_WHEN_PATH_NULL, null)); //"Fragment cannot be set when path is null!"); } else if (!isURIString(p_fragment)) { throw new MalformedURIException(XMLMessages.createXMLMessage(XMLErrorResources.ER_FRAG_INVALID_CHAR, null)); //"Fragment contains invalid character!"); } else { m_fragment = p_fragment; } }
Example 6
Source File: ChunkedIntArray.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Create a new CIA with specified record size. Currently record size MUST * be a power of two... and in fact is hardcoded to 4. */ ChunkedIntArray(int slotsize) { if(this.slotsize<slotsize) throw new ArrayIndexOutOfBoundsException(XMLMessages.createXMLMessage(XMLErrorResources.ER_CHUNKEDINTARRAY_NOT_SUPPORTED, new Object[]{Integer.toString(slotsize)})); //"ChunkedIntArray("+slotsize+") not currently supported"); else if (this.slotsize>slotsize) System.out.println("*****WARNING: ChunkedIntArray("+slotsize+") wasting "+(this.slotsize-slotsize)+" words per slot"); chunks.addElement(fastArray); }
Example 7
Source File: IncrementalSAXSource_Filter.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void init( CoroutineManager co, int controllerCoroutineID, int sourceCoroutineID) { if(co==null) co = new CoroutineManager(); fCoroutineManager = co; fControllerCoroutineID = co.co_joinCoroutineSet(controllerCoroutineID); fSourceCoroutineID = co.co_joinCoroutineSet(sourceCoroutineID); if (fControllerCoroutineID == -1 || fSourceCoroutineID == -1) throw new RuntimeException(XMLMessages.createXMLMessage(XMLErrorResources.ER_COJOINROUTINESET_FAILED, null)); //"co_joinCoroutineSet() failed"); fNoMoreEvents=false; eventcounter=frequency; }
Example 8
Source File: QName.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a new QName with the specified namespace URI, prefix * and local name. * * @param namespaceURI The namespace URI if known, or null * @param prefix The namespace prefix is known, or null * @param localName The local name * @param validate If true the new QName will be validated and an IllegalArgumentException will * be thrown if it is invalid. */ public QName(String namespaceURI, String prefix, String localName, boolean validate) { // This check was already here. So, for now, I will not add it to the validation // that is done when the validate parameter is true. if (localName == null) throw new IllegalArgumentException(XMLMessages.createXMLMessage( XMLErrorResources.ER_ARG_LOCALNAME_NULL, null)); //"Argument 'localName' is null"); if (validate) { if (!XML11Char.isXML11ValidNCName(localName)) { throw new IllegalArgumentException(XMLMessages.createXMLMessage( XMLErrorResources.ER_ARG_LOCALNAME_INVALID,null )); //"Argument 'localName' not a valid NCName"); } if ((null != prefix) && (!XML11Char.isXML11ValidNCName(prefix))) { throw new IllegalArgumentException(XMLMessages.createXMLMessage( XMLErrorResources.ER_ARG_PREFIX_INVALID,null )); //"Argument 'prefix' not a valid NCName"); } } _namespaceURI = namespaceURI; _prefix = prefix; _localName = localName; m_hashCode = toString().hashCode(); }
Example 9
Source File: UnImplNode.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Throw an error. * * @param msg Message Key for the error * @param args Array of arguments to be used in the error message */ public void error(String msg, Object[] args) { System.out.println("DOM ERROR! class: " + this.getClass().getName()); throw new RuntimeException(XMLMessages.createXMLMessage(msg, args)); //"UnImplNode error: "+msg); }
Example 10
Source File: CoroutineManager.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** Transfer control to another coroutine which has already been started and * is waiting on this CoroutineManager. We won't return from this call * until that routine has relinquished control. * * %TBD% What should we do if toCoroutine isn't registered? Exception? * * @param arg_object A value to be passed to the other coroutine. * @param thisCoroutine Integer identifier for this coroutine. This is the * ID we watch for to see if we're the ones being resumed. * @param toCoroutine Integer identifier for the coroutine we wish to * invoke. * @exception java.lang.NoSuchMethodException if toCoroutine isn't a * registered member of this group. %REVIEW% whether this is the best choice. * */ public synchronized Object co_resume(Object arg_object,int thisCoroutine,int toCoroutine) throws java.lang.NoSuchMethodException { if(!m_activeIDs.get(toCoroutine)) throw new java.lang.NoSuchMethodException(XMLMessages.createXMLMessage(XMLErrorResources.ER_COROUTINE_NOT_AVAIL, new Object[]{Integer.toString(toCoroutine)})); //"Coroutine not available, id="+toCoroutine); // We expect these values to be overwritten during the notify()/wait() // periods, as other coroutines in this set get their opportunity to run. m_yield=arg_object; m_nextCoroutine=toCoroutine; notify(); while(m_nextCoroutine != thisCoroutine || m_nextCoroutine==ANYBODY || m_nextCoroutine==NOBODY) { try { // System.out.println("waiting..."); wait(); } catch(java.lang.InterruptedException e) { // %TBD% -- Declare? Encapsulate? Ignore? Or // dance deasil about the program counter? } } if(m_nextCoroutine==NOBODY) { // Pass it along co_exit(thisCoroutine); // And inform this coroutine that its partners are Going Away // %REVIEW% Should this throw/return something more useful? throw new java.lang.NoSuchMethodException(XMLMessages.createXMLMessage(XMLErrorResources.ER_COROUTINE_CO_EXIT, null)); //"CoroutineManager recieved co_exit() request"); } return m_yield; }
Example 11
Source File: UnImplNode.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Throw an error. * * @param msg Message Key for the error */ public void error(String msg) { System.out.println("DOM ERROR! class: " + this.getClass().getName()); throw new RuntimeException(XMLMessages.createXMLMessage(msg, null)); }
Example 12
Source File: IncrementalSAXSource_Filter.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** Launch a thread that will run an XMLReader's parse() operation within * a thread, feeding events to this IncrementalSAXSource_Filter. Mostly a convenience * routine, but has the advantage that -- since we invoked parse() -- * we can halt parsing quickly via a StopException rather than waiting * for the SAX stream to end by itself. * * @throws SAXException is parse thread is already in progress * or parsing can not be started. * */ public void startParse(InputSource source) throws SAXException { if(fNoMoreEvents) throw new SAXException(XMLMessages.createXMLMessage(XMLErrorResources.ER_INCRSAXSRCFILTER_NOT_RESTARTABLE, null)); //"IncrmentalSAXSource_Filter not currently restartable."); if(fXMLReader==null) throw new SAXException(XMLMessages.createXMLMessage(XMLErrorResources.ER_XMLRDR_NOT_BEFORE_STARTPARSE, null)); //"XMLReader not before startParse request"); fXMLReaderInputSource=source; // Xalan thread pooling... // com.sun.org.apache.xalan.internal.transformer.TransformerImpl.runTransformThread(this); ThreadControllerWrapper.runThread(this, -1); }
Example 13
Source File: DTMManagerDefault.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Add a DTM to the DTM table. * * @param dtm Should be a valid reference to a DTM. * @param id Integer DTM ID to be bound to this DTM. * @param offset Integer addressing offset. The internal DTM Node ID is * obtained by adding this offset to the node-number field of the * public DTM Handle. For the first DTM ID accessing each DTM, this is 0; * for overflow addressing it will be a multiple of 1<<IDENT_DTM_NODE_BITS. */ synchronized public void addDTM(DTM dtm, int id, int offset) { if(id>=IDENT_MAX_DTMS) { // TODO: %REVIEW% Not really the right error message. throw new DTMException(XMLMessages.createXMLMessage(XMLErrorResources.ER_NO_DTMIDS_AVAIL, null)); //"No more DTM IDs are available!"); } // We used to just allocate the array size to IDENT_MAX_DTMS. // But we expect to increase that to 16 bits, and I'm not willing // to allocate that much space unless needed. We could use one of our // handy-dandy Fast*Vectors, but this will do for now. // %REVIEW% int oldlen=m_dtms.length; if(oldlen<=id) { // Various growth strategies are possible. I think we don't want // to over-allocate excessively, and I'm willing to reallocate // more often to get that. See also Fast*Vector classes. // // %REVIEW% Should throw a more diagnostic error if we go over the max... int newlen=Math.min((id+256),IDENT_MAX_DTMS); DTM new_m_dtms[] = new DTM[newlen]; System.arraycopy(m_dtms,0,new_m_dtms,0,oldlen); m_dtms=new_m_dtms; int new_m_dtm_offsets[] = new int[newlen]; System.arraycopy(m_dtm_offsets,0,new_m_dtm_offsets,0,oldlen); m_dtm_offsets=new_m_dtm_offsets; } m_dtms[id] = dtm; m_dtm_offsets[id]=offset; dtm.documentRegistration(); // The DTM should have been told who its manager was when we created it. // Do we need to allow for adopting DTMs _not_ created by this manager? }
Example 14
Source File: DefaultErrorHandler.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
public static void printLocation(PrintWriter pw, Throwable exception) { SourceLocator locator = null; Throwable cause = exception; // Try to find the locator closest to the cause. do { if(cause instanceof SAXParseException) { locator = new SAXSourceLocator((SAXParseException)cause); } else if (cause instanceof TransformerException) { SourceLocator causeLocator = ((TransformerException)cause).getLocator(); if(null != causeLocator) locator = causeLocator; } if(cause instanceof TransformerException) cause = ((TransformerException)cause).getCause(); else if(cause instanceof WrappedRuntimeException) cause = ((WrappedRuntimeException)cause).getException(); else if(cause instanceof SAXException) cause = ((SAXException)cause).getException(); else cause = null; } while(null != cause); if(null != locator) { // m_pw.println("Parser fatal error: "+exception.getMessage()); String id = (null != locator.getPublicId() ) ? locator.getPublicId() : (null != locator.getSystemId()) ? locator.getSystemId() : XMLMessages.createXMLMessage(XMLErrorResources.ER_SYSTEMID_UNKNOWN, null); //"SystemId Unknown"; pw.print(id + "; " +XMLMessages.createXMLMessage("line", null) + locator.getLineNumber() + "; " +XMLMessages.createXMLMessage("column", null) + locator.getColumnNumber()+"; "); } else pw.print("("+XMLMessages.createXMLMessage(XMLErrorResources.ER_LOCATION_UNKNOWN, null)+")"); }
Example 15
Source File: DTMDefaultBaseIterators.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Get an iterator that can navigate over an XPath Axis, predicated by * the extended type ID. * Returns an iterator that must be initialized * with a start node (using iterator.setStartNode()). * * @param axis One of Axes.ANCESTORORSELF, etc. * @param type An extended type ID. * * @return A DTMAxisIterator, or null if the given axis isn't supported. */ public DTMAxisIterator getTypedAxisIterator(int axis, int type) { DTMAxisIterator iterator = null; /* This causes an error when using patterns for elements that do not exist in the DOM (translet types which do not correspond to a DOM type are mapped to the DOM.ELEMENT type). */ // if (type == NO_TYPE) { // return(EMPTYITERATOR); // } // else if (type == ELEMENT) { // iterator = new FilterIterator(getAxisIterator(axis), // getElementFilter()); // } // else { switch (axis) { case Axis.SELF : iterator = new TypedSingletonIterator(type); break; case Axis.CHILD : iterator = new TypedChildrenIterator(type); break; case Axis.PARENT : return (new ParentIterator().setNodeType(type)); case Axis.ANCESTOR : return (new TypedAncestorIterator(type)); case Axis.ANCESTORORSELF : return ((new TypedAncestorIterator(type)).includeSelf()); case Axis.ATTRIBUTE : return (new TypedAttributeIterator(type)); case Axis.DESCENDANT : iterator = new TypedDescendantIterator(type); break; case Axis.DESCENDANTORSELF : iterator = (new TypedDescendantIterator(type)).includeSelf(); break; case Axis.FOLLOWING : iterator = new TypedFollowingIterator(type); break; case Axis.PRECEDING : iterator = new TypedPrecedingIterator(type); break; case Axis.FOLLOWINGSIBLING : iterator = new TypedFollowingSiblingIterator(type); break; case Axis.PRECEDINGSIBLING : iterator = new TypedPrecedingSiblingIterator(type); break; case Axis.NAMESPACE : iterator = new TypedNamespaceIterator(type); break; case Axis.ROOT : iterator = new TypedRootIterator(type); break; default : throw new DTMException(XMLMessages.createXMLMessage( XMLErrorResources.ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED, new Object[]{Axis.getNames(axis)})); //"Error: typed iterator for axis " //+ Axis.names[axis] + "not implemented"); } } return (iterator); }
Example 16
Source File: QName.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Construct a QName from a string, resolving the prefix * using the given namespace context and prefix resolver. * The default namespace is not resolved. * * @param qname Qualified name to resolve * @param namespaceContext Namespace Context to use * @param resolver Prefix resolver for this context * @param validate If true the new QName will be validated and an IllegalArgumentException will * be thrown if it is invalid. */ public QName(String qname, Element namespaceContext, PrefixResolver resolver, boolean validate) { _namespaceURI = null; int indexOfNSSep = qname.indexOf(':'); if (indexOfNSSep > 0) { if (null != namespaceContext) { String prefix = qname.substring(0, indexOfNSSep); _prefix = prefix; if (prefix.equals("xml")) { _namespaceURI = S_XMLNAMESPACEURI; } // Do we want this? else if (prefix.equals("xmlns")) { return; } else { _namespaceURI = resolver.getNamespaceForPrefix(prefix, namespaceContext); } if (null == _namespaceURI) { throw new RuntimeException( XMLMessages.createXMLMessage( XMLErrorResources.ER_PREFIX_MUST_RESOLVE, new Object[]{ prefix })); //"Prefix must resolve to a namespace: "+prefix); } } else { // TODO: error or warning... } } _localName = (indexOfNSSep < 0) ? qname : qname.substring(indexOfNSSep + 1); if (validate) { if ((_localName == null) || (!XML11Char.isXML11ValidNCName(_localName))) { throw new IllegalArgumentException(XMLMessages.createXMLMessage( XMLErrorResources.ER_ARG_LOCALNAME_INVALID,null )); //"Argument 'localName' not a valid NCName"); } } m_hashCode = toString().hashCode(); }
Example 17
Source File: QName.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * Construct a QName from a string, resolving the prefix * using the given namespace stack. The default namespace is * not resolved. * * @param qname Qualified name to resolve * @param namespaces Namespace stack to use to resolve namespace * @param validate If true the new QName will be validated and an IllegalArgumentException will * be thrown if it is invalid. */ public QName(String qname, Stack namespaces, boolean validate) { String namespace = null; String prefix = null; int indexOfNSSep = qname.indexOf(':'); if (indexOfNSSep > 0) { prefix = qname.substring(0, indexOfNSSep); if (prefix.equals("xml")) { namespace = S_XMLNAMESPACEURI; } // Do we want this? else if (prefix.equals("xmlns")) { return; } else { int depth = namespaces.size(); for (int i = depth - 1; i >= 0; i--) { NameSpace ns = (NameSpace) namespaces.elementAt(i); while (null != ns) { if ((null != ns.m_prefix) && prefix.equals(ns.m_prefix)) { namespace = ns.m_uri; i = -1; break; } ns = ns.m_next; } } } if (null == namespace) { throw new RuntimeException( XMLMessages.createXMLMessage( XMLErrorResources.ER_PREFIX_MUST_RESOLVE, new Object[]{ prefix })); //"Prefix must resolve to a namespace: "+prefix); } } _localName = (indexOfNSSep < 0) ? qname : qname.substring(indexOfNSSep + 1); if (validate) { if ((_localName == null) || (!XML11Char.isXML11ValidNCName(_localName))) { throw new IllegalArgumentException(XMLMessages.createXMLMessage( XMLErrorResources.ER_ARG_LOCALNAME_INVALID,null )); //"Argument 'localName' not a valid NCName"); } } _namespaceURI = namespace; _prefix = prefix; m_hashCode = toString().hashCode(); }
Example 18
Source File: DTMDefaultBaseIterators.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * Get an iterator that can navigate over an XPath Axis, predicated by * the extended type ID. * Returns an iterator that must be initialized * with a start node (using iterator.setStartNode()). * * @param axis One of Axes.ANCESTORORSELF, etc. * @param type An extended type ID. * * @return A DTMAxisIterator, or null if the given axis isn't supported. */ public DTMAxisIterator getTypedAxisIterator(int axis, int type) { DTMAxisIterator iterator = null; /* This causes an error when using patterns for elements that do not exist in the DOM (translet types which do not correspond to a DOM type are mapped to the DOM.ELEMENT type). */ // if (type == NO_TYPE) { // return(EMPTYITERATOR); // } // else if (type == ELEMENT) { // iterator = new FilterIterator(getAxisIterator(axis), // getElementFilter()); // } // else { switch (axis) { case Axis.SELF : iterator = new TypedSingletonIterator(type); break; case Axis.CHILD : iterator = new TypedChildrenIterator(type); break; case Axis.PARENT : return (new ParentIterator().setNodeType(type)); case Axis.ANCESTOR : return (new TypedAncestorIterator(type)); case Axis.ANCESTORORSELF : return ((new TypedAncestorIterator(type)).includeSelf()); case Axis.ATTRIBUTE : return (new TypedAttributeIterator(type)); case Axis.DESCENDANT : iterator = new TypedDescendantIterator(type); break; case Axis.DESCENDANTORSELF : iterator = (new TypedDescendantIterator(type)).includeSelf(); break; case Axis.FOLLOWING : iterator = new TypedFollowingIterator(type); break; case Axis.PRECEDING : iterator = new TypedPrecedingIterator(type); break; case Axis.FOLLOWINGSIBLING : iterator = new TypedFollowingSiblingIterator(type); break; case Axis.PRECEDINGSIBLING : iterator = new TypedPrecedingSiblingIterator(type); break; case Axis.NAMESPACE : iterator = new TypedNamespaceIterator(type); break; case Axis.ROOT : iterator = new TypedRootIterator(type); break; default : throw new DTMException(XMLMessages.createXMLMessage( XMLErrorResources.ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED, new Object[]{Axis.getNames(axis)})); //"Error: typed iterator for axis " //+ Axis.names[axis] + "not implemented"); } } return (iterator); }
Example 19
Source File: QName.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Construct a QName from a string, resolving the prefix * using the given namespace stack. The default namespace is * not resolved. * * @param qname Qualified name to resolve * @param namespaces Namespace stack to use to resolve namespace * @param validate If true the new QName will be validated and an IllegalArgumentException will * be thrown if it is invalid. */ public QName(String qname, Stack namespaces, boolean validate) { String namespace = null; String prefix = null; int indexOfNSSep = qname.indexOf(':'); if (indexOfNSSep > 0) { prefix = qname.substring(0, indexOfNSSep); if (prefix.equals("xml")) { namespace = S_XMLNAMESPACEURI; } // Do we want this? else if (prefix.equals("xmlns")) { return; } else { int depth = namespaces.size(); for (int i = depth - 1; i >= 0; i--) { NameSpace ns = (NameSpace) namespaces.elementAt(i); while (null != ns) { if ((null != ns.m_prefix) && prefix.equals(ns.m_prefix)) { namespace = ns.m_uri; i = -1; break; } ns = ns.m_next; } } } if (null == namespace) { throw new RuntimeException( XMLMessages.createXMLMessage( XMLErrorResources.ER_PREFIX_MUST_RESOLVE, new Object[]{ prefix })); //"Prefix must resolve to a namespace: "+prefix); } } _localName = (indexOfNSSep < 0) ? qname : qname.substring(indexOfNSSep + 1); if (validate) { if ((_localName == null) || (!XML11Char.isXML11ValidNCName(_localName))) { throw new IllegalArgumentException(XMLMessages.createXMLMessage( XMLErrorResources.ER_ARG_LOCALNAME_INVALID,null )); //"Argument 'localName' not a valid NCName"); } } _namespaceURI = namespace; _prefix = prefix; m_hashCode = toString().hashCode(); }
Example 20
Source File: DTMDefaultBaseIterators.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * This is a shortcut to the iterators that implement the * XPath axes. * Returns a bare-bones iterator that must be initialized * with a start node (using iterator.setStartNode()). * * @param axis One of Axes.ANCESTORORSELF, etc. * * @return A DTMAxisIterator, or null if the given axis isn't supported. */ public DTMAxisIterator getAxisIterator(final int axis) { DTMAxisIterator iterator = null; switch (axis) { case Axis.SELF : iterator = new SingletonIterator(); break; case Axis.CHILD : iterator = new ChildrenIterator(); break; case Axis.PARENT : return (new ParentIterator()); case Axis.ANCESTOR : return (new AncestorIterator()); case Axis.ANCESTORORSELF : return ((new AncestorIterator()).includeSelf()); case Axis.ATTRIBUTE : return (new AttributeIterator()); case Axis.DESCENDANT : iterator = new DescendantIterator(); break; case Axis.DESCENDANTORSELF : iterator = (new DescendantIterator()).includeSelf(); break; case Axis.FOLLOWING : iterator = new FollowingIterator(); break; case Axis.PRECEDING : iterator = new PrecedingIterator(); break; case Axis.FOLLOWINGSIBLING : iterator = new FollowingSiblingIterator(); break; case Axis.PRECEDINGSIBLING : iterator = new PrecedingSiblingIterator(); break; case Axis.NAMESPACE : iterator = new NamespaceIterator(); break; case Axis.ROOT : iterator = new RootIterator(); break; default : throw new DTMException(XMLMessages.createXMLMessage( XMLErrorResources.ER_ITERATOR_AXIS_NOT_IMPLEMENTED, new Object[]{Axis.getNames(axis)})); //"Error: iterator for axis '" + Axis.names[axis] //+ "' not implemented"); } return (iterator); }