本文整理汇总了Java中com.sun.org.apache.xml.internal.serializer.utils.MsgKey类的典型用法代码示例。如果您正苦于以下问题:Java MsgKey类的具体用法?Java MsgKey怎么用?Java MsgKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MsgKey类属于com.sun.org.apache.xml.internal.serializer.utils包,在下文中一共展示了MsgKey类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getNamespaceURI
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* Returns the URI of an element or attribute. Note that default namespaces
* do not apply directly to attributes.
* @param qname a qualified name
* @param isElement true if the qualified name is the name of
* an element.
* @return returns the namespace URI associated with the qualified name.
*/
public String getNamespaceURI(String qname, boolean isElement)
{
String uri = EMPTYSTRING;
int col = qname.lastIndexOf(':');
final String prefix = (col > 0) ? qname.substring(0, col) : EMPTYSTRING;
if (!EMPTYSTRING.equals(prefix) || isElement)
{
if (m_prefixMap != null)
{
uri = m_prefixMap.lookupNamespace(prefix);
if (uri == null && !prefix.equals(XMLNS_PREFIX))
{
throw new RuntimeException(
Utils.messages.createMessage(
MsgKey.ER_NAMESPACE_PREFIX,
new Object[] { qname.substring(0, col) } ));
}
}
}
return uri;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:SerializerBase.java
示例2: getNamespaceURI
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* Returns the URI of an element or attribute. Note that default namespaces
* do not apply directly to attributes.
* @param qname a qualified name
* @param isElement true if the qualified name is the name of
* an element.
* @return returns the namespace URI associated with the qualified name.
*/
public String getNamespaceURI(String qname, boolean isElement) {
String uri = EMPTYSTRING;
int col = qname.lastIndexOf(':');
final String prefix = (col > 0) ? qname.substring(0, col) : EMPTYSTRING;
if (!EMPTYSTRING.equals(prefix) || isElement) {
if (m_prefixMap != null) {
uri = m_prefixMap.lookupNamespace(prefix);
if (uri == null && !prefix.equals(XMLNS_PREFIX)) {
throw new RuntimeException(
Utils.messages.createMessage(
MsgKey.ER_NAMESPACE_PREFIX,
new Object[] { qname.substring(0, col) } ));
}
}
}
return uri;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:SerializerBase.java
示例3: isCDATASectionWellFormed
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* 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));
}
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:DOM3TreeWalker.java
示例4: isTextWellFormed
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* 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));
}
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:DOM3TreeWalker.java
示例5: setEncoding
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
* @param encoding the character encoding
*/
public void setEncoding(String encoding)
{
String old = getEncoding();
super.setEncoding(encoding);
if (old == null || !old.equals(encoding)) {
// If we have changed the setting of the
m_encodingInfo = Encodings.getEncodingInfo(encoding);
if (encoding != null && m_encodingInfo.name == null) {
// We tried to get an EncodingInfo for Object for the given
// encoding, but it came back with an internall null name
// so the encoding is not supported by the JDK, issue a message.
String msg = Utils.messages.createMessage(
MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ encoding });
try
{
// Prepare to issue the warning message
Transformer tran = super.getTransformer();
if (tran != null) {
ErrorListener errHandler = tran.getErrorListener();
// Issue the warning message
if (null != errHandler && m_sourceLocator != null)
errHandler.warning(new TransformerException(msg, m_sourceLocator));
else
System.out.println(msg);
}
else
System.out.println(msg);
}
catch (Exception e){}
}
}
return;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:ToStream.java
示例6: getXMLVersion
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* This method checks for the XML version of output document.
* If XML version of output document is not specified, then output
* document is of version XML 1.0.
* If XML version of output doucment is specified, but it is not either
* XML 1.0 or XML 1.1, a warning message is generated, the XML Version of
* output document is set to XML 1.0 and processing continues.
* @return string (XML version)
*/
private String getXMLVersion()
{
String xmlVersion = getVersion();
if(xmlVersion == null || xmlVersion.equals(XMLVERSION10))
{
xmlVersion = XMLVERSION10;
}
else if(xmlVersion.equals(XMLVERSION11))
{
xmlVersion = XMLVERSION11;
}
else
{
String msg = Utils.messages.createMessage(
MsgKey.ER_XML_VERSION_NOT_SUPPORTED,new Object[]{ xmlVersion });
try
{
// Prepare to issue the warning message
Transformer tran = super.getTransformer();
ErrorListener errHandler = tran.getErrorListener();
// Issue the warning message
if (null != errHandler && m_sourceLocator != null)
errHandler.warning(new TransformerException(msg, m_sourceLocator));
else
System.out.println(msg);
}
catch (Exception e){}
xmlVersion = XMLVERSION10;
}
return xmlVersion;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:ToXMLStream.java
示例7: cdata
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* Receive notification of cdata.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @throws org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*
* @throws org.xml.sax.SAXException
*/
public final void cdata(char ch[], int start, int length)
throws org.xml.sax.SAXException
{
if ((null != m_elemContext.m_elementName)
&& (m_elemContext.m_elementName.equalsIgnoreCase("SCRIPT")
|| m_elemContext.m_elementName.equalsIgnoreCase("STYLE")))
{
try
{
if (m_elemContext.m_startTagOpen)
{
closeStartTag();
m_elemContext.m_startTagOpen = false;
}
m_ispreserve = true;
if (shouldIndent())
indent();
// writer.write(ch, start, length);
writeNormalizedChars(ch, start, length, true, m_lineSepUse);
}
catch (IOException ioe)
{
throw new org.xml.sax.SAXException(
Utils.messages.createMessage(
MsgKey.ER_OIERROR,
null),
ioe);
//"IO error", ioe);
}
}
else
{
super.cdata(ch, start, length);
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:67,代码来源:ToHTMLStream.java
示例8: isElementWellFormed
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* Checks if an element node is well-formed, by checking its Name for well-formedness.
*
* @param data The contents of the comment node
* @return a boolean indiacating if the comment is well-formed or not.
*/
protected void isElementWellFormed(Node node) {
boolean isNameWF = false;
if ((fFeatures & NAMESPACES) != 0) {
isNameWF =
isValidQName(
node.getPrefix(),
node.getLocalName(),
fIsXMLVersion11);
} else {
isNameWF = isXMLName(node.getNodeName(), fIsXMLVersion11);
}
if (!isNameWF) {
String msg =
Utils.messages.createMessage(
MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME,
new Object[] { "Element", node.getNodeName()});
if (fErrorHandler != null) {
fErrorHandler.handleError(
new DOMErrorImpl(
DOMError.SEVERITY_FATAL_ERROR,
msg,
MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME,
null,
null,
null));
}
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:DOM3TreeWalker.java
示例9: cdata
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* Receive notification of cdata.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @throws org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*
* @throws org.xml.sax.SAXException
*/
public final void cdata(char ch[], int start, int length)
throws org.xml.sax.SAXException
{
if ((null != m_elemContext.m_elementName)
&& (m_elemContext.m_elementName.equalsIgnoreCase("SCRIPT")
|| m_elemContext.m_elementName.equalsIgnoreCase("STYLE")))
{
try
{
if (m_elemContext.m_startTagOpen)
{
closeStartTag();
m_elemContext.m_startTagOpen = false;
}
if (shouldIndent())
indent();
// writer.write(ch, start, length);
writeNormalizedChars(ch, start, length, true, m_lineSepUse);
}
catch (IOException ioe)
{
throw new org.xml.sax.SAXException(
Utils.messages.createMessage(
MsgKey.ER_OIERROR,
null),
ioe);
//"IO error", ioe);
}
}
else
{
super.cdata(ch, start, length);
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:64,代码来源:ToHTMLStream.java
示例10: writeUTF16Surrogate
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* Once a surrogate has been detected, write out the pair of
* characters if it is in the encoding, or if there is no
* encoding, otherwise write out an entity reference
* of the value of the unicode code point of the character
* represented by the high/low surrogate pair.
* <p>
* An exception is thrown if there is no low surrogate in the pair,
* because the array ends unexpectely, or if the low char is there
* but its value is such that it is not a low surrogate.
*
* @param c the first (high) part of the surrogate, which
* must be confirmed before calling this method.
* @param ch Character array.
* @param i position Where the surrogate was detected.
* @param end The end index of the significant characters.
* @return 0 if the pair of characters was written out as-is,
* the unicode code point of the character represented by
* the surrogate pair if an entity reference with that value
* was written out.
*
* @throws IOException
* @throws org.xml.sax.SAXException if invalid UTF-16 surrogate detected.
*/
protected int writeUTF16Surrogate(char c, char ch[], int i, int end)
throws IOException
{
int codePoint = 0;
if (i + 1 >= end)
{
throw new IOException(
Utils.messages.createMessage(
MsgKey.ER_INVALID_UTF16_SURROGATE,
new Object[] { Integer.toHexString((int) c)}));
}
final char high = c;
final char low = ch[i+1];
if (!Encodings.isLowUTF16Surrogate(low)) {
throw new IOException(
Utils.messages.createMessage(
MsgKey.ER_INVALID_UTF16_SURROGATE,
new Object[] {
Integer.toHexString((int) c)
+ " "
+ Integer.toHexString(low)}));
}
final java.io.Writer writer = m_writer;
// If we make it to here we have a valid high, low surrogate pair
if (m_encodingInfo.isInEncoding(c,low)) {
// If the character formed by the surrogate pair
// is in the encoding, so just write it out
writer.write(ch,i,2);
}
else {
// Don't know what to do with this char, it is
// not in the encoding and not a high char in
// a surrogate pair, so write out as an entity ref
final String encoding = getEncoding();
if (encoding != null) {
/* The output encoding is known,
* so somthing is wrong.
*/
codePoint = Encodings.toCodePoint(high, low);
// not in the encoding, so write out a character reference
writer.write('&');
writer.write('#');
writer.write(Integer.toString(codePoint));
writer.write(';');
} else {
/* The output encoding is not known,
* so just write it out as-is.
*/
writer.write(ch, i, 2);
}
}
// non-zero only if character reference was written out.
return codePoint;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:82,代码来源:ToStream.java
示例11: characters
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* Receive notification of character data.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param chars The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @throws org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*
* @throws org.xml.sax.SAXException
*/
public final void characters(char chars[], int start, int length)
throws org.xml.sax.SAXException
{
if (m_elemContext.m_isRaw)
{
try
{
if (m_elemContext.m_startTagOpen)
{
closeStartTag();
m_elemContext.m_startTagOpen = false;
}
m_ispreserve = true;
// With m_ispreserve just set true it looks like shouldIndent()
// will always return false, so drop any possible indentation.
// if (shouldIndent())
// indent();
// writer.write("<![CDATA[");
// writer.write(chars, start, length);
writeNormalizedChars(chars, start, length, false, m_lineSepUse);
// writer.write("]]>");
// time to generate characters event
if (m_tracer != null)
super.fireCharEvent(chars, start, length);
return;
}
catch (IOException ioe)
{
throw new org.xml.sax.SAXException(
Utils.messages.createMessage(
MsgKey.ER_OIERROR,
null),
ioe);
//"IO error", ioe);
}
}
else
{
super.characters(chars, start, length);
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:75,代码来源:ToHTMLStream.java
示例12: getParameter
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* This method returns the value of a parameter if known.
*
* @see org.w3c.dom.DOMConfiguration#getParameter(java.lang.String)
*
* @param name A String containing the DOMConfiguration parameter name
* whose value is to be returned.
* @return Object The value of the parameter if known.
*/
public Object getParameter(String name) throws DOMException {
if(name.equalsIgnoreCase(DOMConstants.DOM_NORMALIZE_CHARACTERS)){
return null;
} else if (name.equalsIgnoreCase(DOMConstants.DOM_COMMENTS)) {
return ((fFeatures & COMMENTS) != 0) ? Boolean.TRUE : Boolean.FALSE;
} else if (name.equalsIgnoreCase(DOMConstants.DOM_CDATA_SECTIONS)) {
return ((fFeatures & CDATA) != 0) ? Boolean.TRUE : Boolean.FALSE;
} else if (name.equalsIgnoreCase(DOMConstants.DOM_ENTITIES)) {
return ((fFeatures & ENTITIES) != 0) ? Boolean.TRUE : Boolean.FALSE;
} else if (name.equalsIgnoreCase(DOMConstants.DOM_NAMESPACES)) {
return ((fFeatures & NAMESPACES) != 0) ? Boolean.TRUE : Boolean.FALSE;
} else if (name.equalsIgnoreCase(DOMConstants.DOM_NAMESPACE_DECLARATIONS)) {
return ((fFeatures & NAMESPACEDECLS) != 0) ? Boolean.TRUE : Boolean.FALSE;
} else if (name.equalsIgnoreCase(DOMConstants.DOM_SPLIT_CDATA)) {
return ((fFeatures & SPLITCDATA) != 0) ? Boolean.TRUE : Boolean.FALSE;
} else if (name.equalsIgnoreCase(DOMConstants.DOM_WELLFORMED)) {
return ((fFeatures & WELLFORMED) != 0) ? Boolean.TRUE : Boolean.FALSE;
} else if (name.equalsIgnoreCase(DOMConstants.DOM_DISCARD_DEFAULT_CONTENT)) {
return ((fFeatures & DISCARDDEFAULT) != 0) ? Boolean.TRUE : Boolean.FALSE;
} else if (name.equalsIgnoreCase(DOMConstants.DOM_FORMAT_PRETTY_PRINT)) {
return ((fFeatures & PRETTY_PRINT) != 0) ? Boolean.TRUE : Boolean.FALSE;
} else if (name.equalsIgnoreCase(DOMConstants.DOM_XMLDECL)) {
return ((fFeatures & XMLDECL) != 0) ? Boolean.TRUE : Boolean.FALSE;
} else if (name.equalsIgnoreCase(DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
return ((fFeatures & ELEM_CONTENT_WHITESPACE) != 0) ? Boolean.TRUE : Boolean.FALSE;
} else if (name.equalsIgnoreCase(DOMConstants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) {
return Boolean.TRUE;
} else if (name.equalsIgnoreCase(DOMConstants.DOM_CANONICAL_FORM)
|| name.equalsIgnoreCase(DOMConstants.DOM_CHECK_CHAR_NORMALIZATION)
|| name.equalsIgnoreCase(DOMConstants.DOM_DATATYPE_NORMALIZATION)
// || name.equalsIgnoreCase(DOMConstants.DOM_NORMALIZE_CHARACTERS)
|| name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE)
|| name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE_IF_SCHEMA)) {
return Boolean.FALSE;
} else if (name.equalsIgnoreCase(DOMConstants.DOM_INFOSET)){
if ((fFeatures & ENTITIES) == 0 &&
(fFeatures & CDATA) == 0 &&
(fFeatures & ELEM_CONTENT_WHITESPACE) != 0 &&
(fFeatures & NAMESPACES) != 0 &&
(fFeatures & NAMESPACEDECLS) != 0 &&
(fFeatures & WELLFORMED) != 0 &&
(fFeatures & COMMENTS) != 0) {
return Boolean.TRUE;
}
return Boolean.FALSE;
} else if (name.equalsIgnoreCase(DOMConstants.DOM_ERROR_HANDLER)) {
return fDOMErrorHandler;
} else if (
name.equalsIgnoreCase(DOMConstants.DOM_SCHEMA_LOCATION)
|| name.equalsIgnoreCase(DOMConstants.DOM_SCHEMA_TYPE)) {
return null;
} else {
// Here we have to add the Xalan specific DOM Message Formatter
String msg = Utils.messages.createMessage(
MsgKey.ER_FEATURE_NOT_FOUND,
new Object[] { name });
throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:70,代码来源:LSSerializerImpl.java
示例13: serializeDocType
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* Serializes a Document Type Node.
*
* @param node The Docuemnt Type Node to serialize
* @param bStart Invoked at the start or end of node. Default true.
*/
protected void serializeDocType(DocumentType node, boolean bStart)
throws SAXException {
// The DocType and internalSubset can not be modified in DOM and is
// considered to be well-formed as the outcome of successful parsing.
String docTypeName = node.getNodeName();
String publicId = node.getPublicId();
String systemId = node.getSystemId();
String internalSubset = node.getInternalSubset();
//DocumentType nodes are never passed to the filter
if (internalSubset != null && !"".equals(internalSubset)) {
if (bStart) {
try {
// The Serializer does not provide a way to write out the
// DOCTYPE internal subset via an event call, so we write it
// out here.
Writer writer = fSerializer.getWriter();
StringBuffer dtd = new StringBuffer();
dtd.append("<!DOCTYPE ");
dtd.append(docTypeName);
if (null != publicId) {
dtd.append(" PUBLIC \"");
dtd.append(publicId);
dtd.append('\"');
}
if (null != systemId) {
if (null == publicId) {
dtd.append(" SYSTEM \"");
} else {
dtd.append(" \"");
}
dtd.append(systemId);
dtd.append('\"');
}
dtd.append(" [ ");
dtd.append(fNewLine);
dtd.append(internalSubset);
dtd.append("]>");
dtd.append(fNewLine);
writer.write(dtd.toString());
writer.flush();
} catch (IOException e) {
throw new SAXException(Utils.messages.createMessage(
MsgKey.ER_WRITING_INTERNAL_SUBSET, null), e);
}
} // else if !bStart do nothing
} else {
if (bStart) {
if (fLexicalHandler != null) {
fLexicalHandler.startDTD(docTypeName, publicId, systemId);
}
} else {
if (fLexicalHandler != null) {
fLexicalHandler.endDTD();
}
}
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:75,代码来源:DOM3TreeWalker.java
示例14: recordLocalNSDecl
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* Records local namespace declarations, to be used for normalization later
*
* @param Node, The element node, whose namespace declarations are to be recorded
*/
protected void recordLocalNSDecl(Node node) {
NamedNodeMap atts = ((Element) node).getAttributes();
int length = atts.getLength();
for (int i = 0; i < length; i++) {
Node attr = atts.item(i);
String localName = attr.getLocalName();
String attrPrefix = attr.getPrefix();
String attrValue = attr.getNodeValue();
String attrNS = attr.getNamespaceURI();
localName =
localName == null
|| XMLNS_PREFIX.equals(localName) ? "" : localName;
attrPrefix = attrPrefix == null ? "" : attrPrefix;
attrValue = attrValue == null ? "" : attrValue;
attrNS = attrNS == null ? "" : attrNS;
// check if attribute is a namespace decl
if (XMLNS_URI.equals(attrNS)) {
// No prefix may be bound to http://www.w3.org/2000/xmlns/.
if (XMLNS_URI.equals(attrValue)) {
String msg =
Utils.messages.createMessage(
MsgKey.ER_NS_PREFIX_CANNOT_BE_BOUND,
new Object[] { attrPrefix, XMLNS_URI });
if (fErrorHandler != null) {
fErrorHandler.handleError(
new DOMErrorImpl(
DOMError.SEVERITY_ERROR,
msg,
MsgKey.ER_NS_PREFIX_CANNOT_BE_BOUND,
null,
null,
null));
}
} else {
// store the namespace-declaration
if (XMLNS_PREFIX.equals(attrPrefix) ) {
// record valid decl
if (attrValue.length() != 0) {
fNSBinder.declarePrefix(localName, attrValue);
} else {
// Error; xmlns:prefix=""
}
} else { // xmlns
// empty prefix is always bound ("" or some string)
fNSBinder.declarePrefix("", attrValue);
}
}
}
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:63,代码来源:DOM3TreeWalker.java
示例15: fixupElementNS
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* Fixes an element's namespace
*
* @param Node, The element node, whose namespace is to be fixed
*/
protected void fixupElementNS(Node node) throws SAXException {
String namespaceURI = ((Element) node).getNamespaceURI();
String prefix = ((Element) node).getPrefix();
String localName = ((Element) node).getLocalName();
if (namespaceURI != null) {
//if ( Element's prefix/namespace pair (or default namespace,
// if no prefix) are within the scope of a binding )
prefix = prefix == null ? "" : prefix;
String inScopeNamespaceURI = fNSBinder.getURI(prefix);
if ((inScopeNamespaceURI != null
&& inScopeNamespaceURI.equals(namespaceURI))) {
// do nothing, declaration in scope is inherited
} else {
// Create a local namespace declaration attr for this namespace,
// with Element's current prefix (or a default namespace, if
// no prefix). If there's a conflicting local declaration
// already present, change its value to use this namespace.
// Add the xmlns declaration attribute
//fNSBinder.pushNamespace(prefix, namespaceURI, fElementDepth);
if ((fFeatures & NAMESPACEDECLS) != 0) {
if ("".equals(prefix) || "".equals(namespaceURI)) {
((Element)node).setAttributeNS(XMLNS_URI, XMLNS_PREFIX, namespaceURI);
} else {
((Element)node).setAttributeNS(XMLNS_URI, XMLNS_PREFIX + ":" + prefix, namespaceURI);
}
}
fLocalNSBinder.declarePrefix(prefix, namespaceURI);
fNSBinder.declarePrefix(prefix, namespaceURI);
}
} else {
// Element has no namespace
// DOM Level 1
if (localName == null || "".equals(localName)) {
// DOM Level 1 node!
String msg =
Utils.messages.createMessage(
MsgKey.ER_NULL_LOCAL_ELEMENT_NAME,
new Object[] { node.getNodeName()});
if (fErrorHandler != null) {
fErrorHandler.handleError(
new DOMErrorImpl(
DOMError.SEVERITY_ERROR,
msg,
MsgKey.ER_NULL_LOCAL_ELEMENT_NAME,
null,
null,
null));
}
} else {
namespaceURI = fNSBinder.getURI("");
if (namespaceURI !=null && namespaceURI.length() > 0) {
((Element)node).setAttributeNS(XMLNS_URI, XMLNS_PREFIX, "");
fLocalNSBinder.declarePrefix("", "");
fNSBinder.declarePrefix("", "");
}
}
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:70,代码来源:DOM3TreeWalker.java
示例16: writeUTF16Surrogate
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* Once a surrogate has been detected, write out the pair of
* characters if it is in the encoding, or if there is no
* encoding, otherwise write out an entity reference
* of the value of the unicode code point of the character
* represented by the high/low surrogate pair.
* <p>
* An exception is thrown if there is no low surrogate in the pair,
* because the array ends unexpectely, or if the low char is there
* but its value is such that it is not a low surrogate.
*
* @param c the first (high) part of the surrogate, which
* must be confirmed before calling this method.
* @param ch Character array.
* @param i position Where the surrogate was detected.
* @param end The end index of the significant characters.
* @return 0 if the pair of characters was written out as-is,
* the unicode code point of the character represented by
* the surrogate pair if an entity reference with that value
* was written out.
*
* @throws IOException
* @throws org.xml.sax.SAXException if invalid UTF-16 surrogate detected.
*/
protected int writeUTF16Surrogate(char c, char ch[], int i, int end)
throws IOException
{
int codePoint = 0;
if (i + 1 >= end)
{
throw new IOException(
Utils.messages.createMessage(
MsgKey.ER_INVALID_UTF16_SURROGATE,
new Object[] { Integer.toHexString((int) c)}));
}
final char high = c;
final char low = ch[i+1];
if (!Encodings.isLowUTF16Surrogate(low)) {
throw new IOException(
Utils.messages.createMessage(
MsgKey.ER_INVALID_UTF16_SURROGATE,
new Object[] {
Integer.toHexString((int) c)
+ " "
+ Integer.toHexString(low)}));
}
final Writer writer = m_writer;
// If we make it to here we have a valid high, low surrogate pair
if (m_encodingInfo.isInEncoding(c,low)) {
// If the character formed by the surrogate pair
// is in the encoding, so just write it out
writer.write(ch,i,2);
}
else {
// Don't know what to do with this char, it is
// not in the encoding and not a high char in
// a surrogate pair, so write out as an entity ref
final String encoding = getEncoding();
if (encoding != null) {
/* The output encoding is known,
* so somthing is wrong.
*/
codePoint = Encodings.toCodePoint(high, low);
// not in the encoding, so write out a character reference
writer.write('&');
writer.write('#');
writer.write(Integer.toString(codePoint));
writer.write(';');
} else {
/* The output encoding is not known,
* so just write it out as-is.
*/
writer.write(ch, i, 2);
}
}
// non-zero only if character reference was written out.
return codePoint;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:82,代码来源:ToStream.java
示例17: characters
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; //导入依赖的package包/类
/**
* Receive notification of character data.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param chars The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @throws org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*
* @throws org.xml.sax.SAXException
*/
public final void characters(char chars[], int start, int length)
throws org.xml.sax.SAXException
{
if (m_elemContext.m_isRaw)
{
try
{
if (m_elemContext.m_startTagOpen)
{
closeStartTag();
m_elemContext.m_startTagOpen = false;
}
// With m_ispreserve just set true it looks like shouldIndent()
// will always return false, so drop any possible indentation.
// if (shouldIndent())
// indent();
// writer.write("<![CDATA[");
// writer.write(chars, start, length);
writeNormalizedChars(chars, start, length, false, m_lineSepUse);
m_isprevtext = true;
// writer.write("]]>");
// time to generate characters event
if (m_tracer != null)
super.fireCharEvent(chars, start, length);
return;
}
catch (IOException ioe)
{
throw new org.xml.sax.SAXException(
Utils.messages.createMessage(
MsgKey.ER_OIERROR,
null),
ioe);
//"IO error", ioe);
}
}
else
{
super.characters(chars, start, length);
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:74,代码来源:ToHTMLStream.java
注:本文中的com.sun.org.apache.xml.internal.serializer.utils.MsgKey类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论