/** * This method returns a of the parameters supported by this DOMConfiguration object * and for which at least one value can be set by the application * * @see org.w3c.dom.DOMConfiguration#getParameterNames() * * @return DOMStringList A list of DOMConfiguration parameters recognized * by the serializer */ public DOMStringList getParameterNames() { return new DOMStringListImpl(fRecognizedParameters); }
/** * Return a {@link DOM3Serializer} interface into this serializer. If the * serializer does not support the {@link DOM3Serializer} interface, it should * return null. * * @return A {@link DOM3Serializer} interface into this serializer, or null * if the serializer is not DOM capable * @throws IOException An I/O exception occured * @see org.apache.xml.serializer.Serializer#asDOM3Serializer() */ public Object asDOM3Serializer() throws IOException { return new org.apache.xml.serializer.dom3.DOM3SerializerImpl(this); } /**
/** * @see org.apache.xerces.xni.NamespaceContext#getAllPrefixes() */ public Enumeration getAllPrefixes() { int count = 0; if (fPrefixes.length < (fNamespace.length/2)) { // resize prefix array String[] prefixes = new String[fNamespaceSize]; fPrefixes = prefixes; } String prefix = null; boolean unique = true; for (int i = 2; i < (fNamespaceSize-2); i += 2) { prefix = fNamespace[i + 2]; for (int k=0;k<count;k++){ if (fPrefixes[k]==prefix){ unique = false; break; } } if (unique){ fPrefixes[count++] = prefix; } unique = true; } return new Prefixes(fPrefixes, count); }
isElementWellFormed(node); if (!applyFilter(node, NodeFilter.SHOW_ELEMENT)) { return; fNSBinder.pushContext(); fLocalNSBinder.reset(); recordLocalNSDecl(node); fixupElementNS(node); node.getNodeName()); serializeAttList(node); if (!applyFilter(node, NodeFilter.SHOW_ELEMENT)) { return; fNSBinder.popContext();
isCDATASectionWellFormed(node); new DOMErrorImpl( DOMError.SEVERITY_WARNING, msg, new DOMErrorImpl( DOMError.SEVERITY_ERROR, msg, if (!applyFilter(node, NodeFilter.SHOW_CDATA_SECTION)) { return; fLexicalHandler.startCDATA(); dispatachChars(node); if (fLexicalHandler != null) { fLexicalHandler.endCDATA(); dispatachChars(node);
/** * End processing of given node * * * @param node Node we just finished processing * * @throws org.xml.sax.SAXException */ protected void endNode(Node node) throws org.xml.sax.SAXException { switch (node.getNodeType()) { case Node.DOCUMENT_NODE : break; case Node.DOCUMENT_TYPE_NODE : serializeDocType((DocumentType) node, false); break; case Node.ELEMENT_NODE : serializeElement((Element) node, false); break; case Node.CDATA_SECTION_NODE : break; case Node.ENTITY_REFERENCE_NODE : serializeEntityReference((EntityReference) node, false); break; default : } }
if ((fFeatures & NAMESPACES) != 0) { isNameWF = isValidQName( node.getPrefix(), node.getLocalName(), fIsXMLVersion11); } else { isNameWF = isXMLName(node.getNodeName(), fIsXMLVersion11); new DOMErrorImpl( DOMError.SEVERITY_FATAL_ERROR, msg,
javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, ""); dispatachChars(node); fSerializer.processingInstruction( javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, isTextWellFormed(node); if (!applyFilter(node, NodeFilter.SHOW_TEXT)) { return; dispatachChars(node);
&& fNSBinder.getURI(prefix) == null) { String msg = Utils.messages.createMessage( new DOMErrorImpl( DOMError.SEVERITY_FATAL_ERROR, msg, String attrPrefix = attrs.item(i).getPrefix(); if (attrPrefix != null && fNSBinder.getURI(attrPrefix) == null) { String msg = Utils.messages.createMessage( new DOMErrorImpl( DOMError.SEVERITY_FATAL_ERROR, msg, checkUnboundPrefixInEntRef(child);
String inScopeNamespaceURI = fNSBinder.getURI(prefix); fLocalNSBinder.declarePrefix(prefix, namespaceURI); fNSBinder.declarePrefix(prefix, namespaceURI); new DOMErrorImpl( DOMError.SEVERITY_ERROR, msg, namespaceURI = fNSBinder.getURI(""); if (namespaceURI !=null && namespaceURI.length() > 0) { ((Element)node).setAttributeNS(XMLNS_URI, XMLNS_PREFIX, ""); fLocalNSBinder.declarePrefix("", ""); fNSBinder.declarePrefix("", "");
if (!isXMLName(node.getNodeName(), fIsXMLVersion11)) { String msg = Utils.messages.createMessage( new DOMErrorImpl( DOMError.SEVERITY_FATAL_ERROR, msg, Character invalidChar = isWFXMLChar(node.getData()); if (invalidChar != null) { String msg = new DOMErrorImpl( DOMError.SEVERITY_FATAL_ERROR, msg,
/** * Checks if an Text node is well-formed, by checking if it contains invalid * XML characters. * * @param data The contents of the comment node */ protected void isTextWellFormed(Text node) { // Does the data valid XML character data Character invalidChar = isWFXMLChar(node.getData()); if (invalidChar != null) { String msg = Utils.messages.createMessage( MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT, new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) }); if (fErrorHandler != null) { fErrorHandler.handleError( new DOMErrorImpl( DOMError.SEVERITY_FATAL_ERROR, msg, MsgKey.ER_WF_INVALID_CHARACTER, null, null, null)); } } }
/** * Serializes the Level 3 DOM node by creating an instance of DOM3TreeWalker * which traverses the DOM tree and invokes handler events to serialize * the DOM NOde. Throws an exception only if an I/O exception occured * while serializing. * This interface is a public API. * * @param node the Level 3 DOM node to serialize * @throws IOException if an I/O exception occured while serializing */ public void serializeDOM3(Node node) throws IOException { try { DOM3TreeWalker walker = new DOM3TreeWalker(fSerializationHandler, fErrorHandler, fSerializerFilter, fNewLine); walker.traverse(node); } catch (org.xml.sax.SAXException se) { throw new WrappedRuntimeException(se); } }
/** * Constructor. * @param contentHandler serialHandler The implemention of the SerializationHandler interface */ DOM3TreeWalker( SerializationHandler serialHandler, DOMErrorHandler errHandler, LSSerializerFilter filter, String newLine) { fSerializer = serialHandler; //fErrorHandler = errHandler == null ? new DOMErrorHandlerImpl() : errHandler; // Should we be using the default? fErrorHandler = errHandler; fFilter = filter; fLexicalHandler = null; fNewLine = newLine; fNSBinder = new NamespaceSupport(); fLocalNSBinder = new NamespaceSupport(); fDOMConfigProperties = fSerializer.getOutputFormat(); fSerializer.setDocumentLocator(fLocator); initProperties(fDOMConfigProperties); try { // Bug see Bugzilla 26741 fLocator.setSystemId( System.getProperty("user.dir") + File.separator + "dummy.xsl"); } catch (SecurityException se) { // user.dir not accessible from applet } }
/** * Serializes a Comment Node. * * @param node The Comment Node to serialize */ protected void serializeComment(Comment node) throws SAXException { // comments=true if ((fFeatures & COMMENTS) != 0) { String data = node.getData(); // well-formed=true if ((fFeatures & WELLFORMED) != 0) { isCommentWellFormed(data); } if (fLexicalHandler != null) { // apply the LSSerializer filter after the operations requested by the // DOMConfiguration parameters have been applied if (!applyFilter(node, NodeFilter.SHOW_COMMENT)) { return; } fLexicalHandler.comment(data.toCharArray(), 0, data.length()); } } }
/** * Serializes an ProcessingInstruction Node. * * @param node The ProcessingInstruction Node to serialize */ protected void serializePI(ProcessingInstruction node) throws SAXException { ProcessingInstruction pi = node; String name = pi.getNodeName(); // well-formed=true if ((fFeatures & WELLFORMED) != 0) { isPIWellFormed(node); } // apply the LSSerializer filter if (!applyFilter(node, NodeFilter.SHOW_PROCESSING_INSTRUCTION)) { return; } // String data = pi.getData(); if (name.equals("xslt-next-is-raw")) { fNextIsRaw = true; } else { this.fSerializer.processingInstruction(name, pi.getData()); } }
/** * @see org.apache.xerces.xni.NamespaceContext#getPrefix(String) */ public String getPrefix(String uri) { // find uri in current context for (int i = fNamespaceSize; i > 0; i -= 2) { //if (fNamespace[i - 1] == uri) { if (fNamespace[i - 1].equals(uri) ) { //if (getURI(fNamespace[i - 2]) == uri) if (getURI(fNamespace[i - 2]).equals(uri) ) return fNamespace[i - 2]; } } // uri not found return null; } // getPrefix(String):String
/** * Replaces all escape sequences in the given path with their literal characters. */ private static String getPathWithoutEscapes(String origPath) { if (origPath != null && origPath.length() != 0 && origPath.indexOf('%') != -1) { // Locate the escape characters StringTokenizer tokenizer = new StringTokenizer(origPath, "%"); StringBuffer result = new StringBuffer(origPath.length()); int size = tokenizer.countTokens(); result.append(tokenizer.nextToken()); for(int i = 1; i < size; ++i) { String token = tokenizer.nextToken(); if (token.length() >= 2 && isHexDigit(token.charAt(0)) && isHexDigit(token.charAt(1))) { // Decode the 2 digit hexadecimal number following % in '%nn' result.append((char)Integer.valueOf(token.substring(0, 2), 16).intValue()); token = token.substring(2); } result.append(token); } return result.toString(); } return origPath; }
/** * Checks if an CDATASection node is well-formed, by checking it's data * for well-formedness. Note that the presence of a CDATA termination mark * in the contents of a CDATASection is handled by the parameter * spli-cdata-sections * * @param data The contents of the comment node */ protected void isCDATASectionWellFormed(CDATASection node) { // Does the data valid XML character data Character invalidChar = isWFXMLChar(node.getData()); //if (!isWFXMLChar(node.getData(), invalidChar)) { if (invalidChar != null) { String msg = Utils.messages.createMessage( MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA, new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) }); if (fErrorHandler != null) { fErrorHandler.handleError( new DOMErrorImpl( DOMError.SEVERITY_FATAL_ERROR, msg, MsgKey.ER_WF_INVALID_CHARACTER, null, null, null)); } } }