本文整理汇总了Java中com.sun.org.apache.xerces.internal.util.XMLChar类的典型用法代码示例。如果您正苦于以下问题:Java XMLChar类的具体用法?Java XMLChar怎么用?Java XMLChar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XMLChar类属于com.sun.org.apache.xerces.internal.util包,在下文中一共展示了XMLChar类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: isValidQName
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
/**
* Checks if the given qualified name is legal with respect
* to the version of XML to which this document must conform.
*
* @param prefix prefix of qualified name
* @param local local part of qualified name
*/
public static final boolean isValidQName(String prefix, String local, boolean xml11Version) {
// check that both prefix and local part match NCName
if (local == null) return false;
boolean validNCName = false;
if (!xml11Version) {
validNCName = (prefix == null || XMLChar.isValidNCName(prefix))
&& XMLChar.isValidNCName(local);
}
else {
validNCName = (prefix == null || XML11Char.isXML11ValidNCName(prefix))
&& XML11Char.isXML11ValidNCName(local);
}
return validNCName;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:CoreDocumentImpl.java
示例2: validate
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
/**
* Checks that "content" string is valid ID value.
* If invalid a Datatype validation exception is thrown.
*
* @param content the string value that needs to be validated
* @param context the validation context
* @throws InvalidDatatypeException if the content is
* invalid according to the rules for the validators
* @see InvalidDatatypeValueException
*/
public void validate(String content, ValidationContext context) throws InvalidDatatypeValueException {
//Check if is valid key-[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
if(context.useNamespaces()) {
if (!XMLChar.isValidNCName(content)) {
throw new InvalidDatatypeValueException("IDInvalidWithNamespaces", new Object[]{content});
}
}
else {
if (!XMLChar.isValidName(content)) {
throw new InvalidDatatypeValueException("IDInvalid", new Object[]{content});
}
}
if (context.isIdDeclared(content)) {
throw new InvalidDatatypeValueException("IDNotUnique", new Object[]{content});
}
context.addId(content);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:IDDatatypeValidator.java
示例3: validate
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
/**
* Checks that "content" string is valid IDREF value.
* If invalid a Datatype validation exception is thrown.
*
* @param content the string value that needs to be validated
* @param context the validation context
* @throws InvalidDatatypeException if the content is
* invalid according to the rules for the validators
* @see InvalidDatatypeValueException
*/
public void validate(String content, ValidationContext context) throws InvalidDatatypeValueException {
//Check if is valid key-[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
if(context.useNamespaces()) {
if (!XMLChar.isValidNCName(content)) {
throw new InvalidDatatypeValueException("IDREFInvalidWithNamespaces", new Object[]{content});
}
}
else {
if (!XMLChar.isValidName(content)) {
throw new InvalidDatatypeValueException("IDREFInvalid", new Object[]{content});
}
}
context.addIdRef(content);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:IDREFDatatypeValidator.java
示例4: isValidQName
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
/**
* Taken from org.apache.xerces.dom.CoreDocumentImpl
*
* Checks if the given qualified name is legal with respect
* to the version of XML to which this document must conform.
*
* @param prefix prefix of qualified name
* @param local local part of qualified name
*/
protected boolean isValidQName(
String prefix,
String local,
boolean xml11Version) {
// check that both prefix and local part match NCName
if (local == null)
return false;
boolean validNCName = false;
if (!xml11Version) {
validNCName =
(prefix == null || XMLChar.isValidNCName(prefix))
&& XMLChar.isValidNCName(local);
} else {
validNCName =
(prefix == null || XML11Char.isXML11ValidNCName(prefix))
&& XML11Char.isXML11ValidNCName(local);
}
return validNCName;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:DOM3TreeWalker.java
示例5: normalize
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
private static String normalize(String xpath) {
// NOTE: We have to prefix the selector XPath with "./" in
// order to handle selectors such as "." that select
// the element container because the fields could be
// relative to that element. -Ac
// Unless xpath starts with a descendant node -Achille Fokoue
// ... or a '.' or a '/' - NG
// And we also need to prefix exprs to the right of | with ./ - NG
StringBuffer modifiedXPath = new StringBuffer(xpath.length()+5);
int unionIndex = -1;
do {
if(!(XMLChar.trim(xpath).startsWith("/") || XMLChar.trim(xpath).startsWith("."))) {
modifiedXPath.append("./");
}
unionIndex = xpath.indexOf('|');
if(unionIndex == -1) {
modifiedXPath.append(xpath);
break;
}
modifiedXPath.append(xpath.substring(0,unionIndex+1));
xpath = xpath.substring(unionIndex+1, xpath.length());
} while(true);
return modifiedXPath.toString();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:Selector.java
示例6: isValidQName
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
/**
* Checks if the given qualified name is legal with respect
* to the version of XML to which this document must conform.
*
* @param prefix prefix of qualified name
* @param local local part of qualified name
*/
public static final boolean isValidQName(String prefix, String local, boolean xml11Version) {
// check that both prefix and local part match NCName
if (local == null) return false;
boolean validNCName = false;
if (!xml11Version) {
validNCName = (prefix == null || XMLChar.isValidNCName(prefix))
&& XMLChar.isValidNCName(local);
}
else {
validNCName = (prefix == null || XML11Char.isXML11ValidNCName(prefix))
&& XML11Char.isXML11ValidNCName(local);
}
return validNCName;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:CoreDocumentImpl.java
示例7: skipDTD
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
/**
* Skip the DTD if javax.xml.stream.supportDTD is false.
*
* @param supportDTD The value of the property javax.xml.stream.supportDTD.
* @return true if DTD is skipped, false otherwise.
* @throws java.io.IOException if i/o error occurs
*/
@Override
public boolean skipDTD(boolean supportDTD) throws IOException {
if (supportDTD)
return false;
fStringBuffer.clear();
while (fEntityScanner.scanData("]", fStringBuffer, 0)) {
int c = fEntityScanner.peekChar();
if (c != -1) {
if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer);
}
if (isInvalidLiteral(c)) {
reportFatalError("InvalidCharInDTD",
new Object[] { Integer.toHexString(c) });
fEntityScanner.scanChar(null);
}
}
}
fEntityScanner.fCurrentEntity.position--;
return true;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:XMLDTDScannerImpl.java
示例8: isXMLName
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
/**
* Check the string against XML's definition of acceptable names for
* elements and attributes and so on using the XMLCharacterProperties
* utility class
*/
public static final boolean isXMLName(String s, boolean xml11Version) {
if (s == null) {
return false;
}
if(!xml11Version)
return XMLChar.isValidName(s);
else
return XML11Char.isXML11ValidName(s);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:CoreDocumentImpl.java
示例9: checkQName
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
/**
* Checks if the given qualified name is legal with respect
* to the version of XML to which this document must conform.
*
* @param prefix prefix of qualified name
* @param local local part of qualified name
*/
protected final void checkQName(String prefix, String local) {
if (!errorChecking) {
return;
}
// check that both prefix and local part match NCName
boolean validNCName = false;
if (!xml11Version) {
validNCName = (prefix == null || XMLChar.isValidNCName(prefix))
&& XMLChar.isValidNCName(local);
}
else {
validNCName = (prefix == null || XML11Char.isXML11ValidNCName(prefix))
&& XML11Char.isXML11ValidNCName(local);
}
if (!validNCName) {
// REVISIT: add qname parameter to the message
String msg =
DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"INVALID_CHARACTER_ERR",
null);
throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:CoreDocumentImpl.java
示例10: surrogates
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
protected final void surrogates(int high, int low, boolean inContent) throws IOException{
if (XMLChar.isHighSurrogate(high)) {
if (!XMLChar.isLowSurrogate(low)) {
//Invalid XML
fatalError("The character '"+(char)low+"' is an invalid XML character");
}
else {
int supplemental = XMLChar.supplemental((char)high, (char)low);
if (!XML11Char.isXML11Valid(supplemental)) {
//Invalid XML
fatalError("The character '"+(char)supplemental+"' is an invalid XML character");
}
else {
if (inContent && content().inCData) {
_printer.printText("]]>&#x");
_printer.printText(Integer.toHexString(supplemental));
_printer.printText(";<![CDATA[");
}
else {
printHex(supplemental);
}
}
}
}
else {
fatalError("The character '"+(char)high+"' is an invalid XML character");
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:XML11Serializer.java
示例11: isIgnorableWhiteSpace
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
public boolean isIgnorableWhiteSpace(XMLString text) {
if (isInElementContent()) {
for (int i = text.offset; i < text.offset + text.length; i++) {
if (!XMLChar.isSpace(text.ch[i])) {
return false;
}
}
return true;
}
return false;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:DTDGrammarUtil.java
示例12: getActualValue
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
public Object getActualValue(String content, ValidationContext context)
throws InvalidDatatypeValueException {
// "prefix:localpart" or "localpart"
// get prefix and local part out of content
String prefix, localpart;
int colonptr = content.indexOf(":");
if (colonptr > 0) {
prefix = context.getSymbol(content.substring(0,colonptr));
localpart = content.substring(colonptr+1);
} else {
prefix = EMPTY_STRING;
localpart = content;
}
// both prefix (if any) a nd localpart must be valid NCName
if (prefix.length() > 0 && !XMLChar.isValidNCName(prefix))
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "QName"});
if(!XMLChar.isValidNCName(localpart))
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "QName"});
// resove prefix to a uri, report an error if failed
String uri = context.getURI(prefix);
if (prefix.length() > 0 && uri == null)
throw new InvalidDatatypeValueException("UndeclaredPrefix", new Object[]{content, prefix});
return new XQName(prefix, context.getSymbol(localpart), context.getSymbol(content), uri);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:QNameDV.java
示例13: getActualValue
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
if (!XMLChar.isValidNCName(content)) {
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "NCName"});
}
return content;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:EntityDV.java
示例14: isWhiteSpace
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
/**
* Returns true if the cursor points to a character data event that consists of all whitespace
* Application calling this method needs to cache the value and avoid calling this method again
* for the same event.
* @return
*/
public boolean isWhiteSpace() {
if(isCharacters() || (fEventType == XMLStreamConstants.CDATA)){
char [] ch = this.getTextCharacters();
final int start = this.getTextStart();
final int end = start + this.getTextLength();
for (int i = start; i < end; i++){
if(!XMLChar.isSpace(ch[i])){
return false;
}
}
return true;
}
return false;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:XMLStreamReaderImpl.java
示例15: normalizeWhitespace
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
/**
* Normalize whitespace in an XMLString converting all whitespace
* characters to space characters.
*/
protected void normalizeWhitespace(XMLString value) {
int end = value.offset + value.length;
for (int i = value.offset; i < end; ++i) {
int c = value.ch[i];
if (XMLChar.isSpace(c)) {
value.ch[i] = ' ';
}
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:XML11DTDScannerImpl.java
示例16: isUnchangedByNormalization
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
/**
* Checks whether this string would be unchanged by normalization.
*
* @return -1 if the value would be unchanged by normalization,
* otherwise the index of the first whitespace character which
* would be transformed.
*/
protected int isUnchangedByNormalization(XMLString value) {
int end = value.offset + value.length;
for (int i = value.offset; i < end; ++i) {
int c = value.ch[i];
if (XMLChar.isSpace(c)) {
return i - value.offset;
}
}
return -1;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:XML11DTDScannerImpl.java
示例17: characters
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
/**
* Character content.
*
* @param text The content.
* @param augs Additional information that may include infoset augmentations
*
* @exception XNIException
* Thrown by handler to signal an error.
*/
public void characters(XMLString text, Augmentations augs) throws XNIException {
// when it's not within xs:appinfo or xs:documentation
if (fInnerAnnotationDepth == -1 ) {
for (int i=text.offset; i<text.offset+text.length; i++) {
// and there is a non-whitespace character
if (!XMLChar.isSpace(text.ch[i])) {
// the string we saw: starting from the first non-whitespace character.
String txt = new String(text.ch, i, text.length+text.offset-i);
// report an error
fErrorReporter.reportError(fLocator,
XSMessageFormatter.SCHEMA_DOMAIN,
"s4s-elt-character",
new Object[]{txt},
XMLErrorReporter.SEVERITY_ERROR);
break;
}
}
// don't call super.characters() when it's not within one of the 2
// annotation elements: the traversers ignore them anyway. We can
// save time/memory creating the text nodes.
}
// when it's within either of the 2 elements, characters are allowed
// and we need to store them.
else {
schemaDOM.characters(text);
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:SchemaDOMParser.java
示例18: characterData
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
public boolean characterData(String data, Augmentations augs) {
fSawText = fSawText || data.length() > 0;
// REVISIT: this methods basically duplicates implementation of
// handleCharacters(). We should be able to reuse some code
// if whitespace == -1 skip normalization, because it is a complexType
// or a union type.
if (fNormalizeData && fWhiteSpace != -1 && fWhiteSpace != XSSimpleType.WS_PRESERVE) {
// normalize data
normalizeWhitespace(data, fWhiteSpace == XSSimpleType.WS_COLLAPSE);
fBuffer.append(fNormalizedStr.ch, fNormalizedStr.offset, fNormalizedStr.length);
} else {
if (fAppendBuffer)
fBuffer.append(data);
}
// When it's a complex type with element-only content, we need to
// find out whether the content contains any non-whitespace character.
boolean allWhiteSpace = true;
if (fCurrentType != null
&& fCurrentType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
XSComplexTypeDecl ctype = (XSComplexTypeDecl) fCurrentType;
if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_ELEMENT) {
// data outside of element content
for (int i = 0; i < data.length(); i++) {
if (!XMLChar.isSpace(data.charAt(i))) {
allWhiteSpace = false;
fSawCharacters = true;
break;
}
}
}
}
return allWhiteSpace;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:XMLSchemaValidator.java
示例19: handleCharacters
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
XMLString handleCharacters(XMLString text) {
if (fSkipValidationDepth >= 0)
return text;
fSawText = fSawText || text.length > 0;
// Note: data in EntityRef and CDATA is normalized as well
// if whitespace == -1 skip normalization, because it is a complexType
// or a union type.
if (fNormalizeData && fWhiteSpace != -1 && fWhiteSpace != XSSimpleType.WS_PRESERVE) {
// normalize data
normalizeWhitespace(text, fWhiteSpace == XSSimpleType.WS_COLLAPSE);
text = fNormalizedStr;
}
if (fAppendBuffer)
fBuffer.append(text.ch, text.offset, text.length);
// When it's a complex type with element-only content, we need to
// find out whether the content contains any non-whitespace character.
fSawOnlyWhitespaceInElementContent = false;
if (fCurrentType != null
&& fCurrentType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
XSComplexTypeDecl ctype = (XSComplexTypeDecl) fCurrentType;
if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_ELEMENT) {
// data outside of element content
for (int i = text.offset; i < text.offset + text.length; i++) {
if (!XMLChar.isSpace(text.ch[i])) {
fSawCharacters = true;
break;
}
fSawOnlyWhitespaceInElementContent = !fSawCharacters;
}
}
}
return text;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:XMLSchemaValidator.java
示例20: normalizeWhitespace
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入依赖的package包/类
private void normalizeWhitespace(String value, boolean collapse) {
boolean skipSpace = collapse;
char c;
int size = value.length();
// ensure the ch array is big enough
if (fNormalizedStr.ch == null || fNormalizedStr.ch.length < size) {
fNormalizedStr.ch = new char[size];
}
fNormalizedStr.offset = 0;
fNormalizedStr.length = 0;
for (int i = 0; i < size; i++) {
c = value.charAt(i);
if (XMLChar.isSpace(c)) {
if (!skipSpace) {
// take the first whitespace as a space and skip the others
fNormalizedStr.ch[fNormalizedStr.length++] = ' ';
skipSpace = collapse;
}
} else {
fNormalizedStr.ch[fNormalizedStr.length++] = c;
skipSpace = false;
}
}
if (skipSpace) {
if (fNormalizedStr.length != 0)
// if we finished on a space trim it but also record it
fNormalizedStr.length--;
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:XMLSchemaValidator.java
注:本文中的com.sun.org.apache.xerces.internal.util.XMLChar类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论