本文整理汇总了Java中com.sun.org.apache.xerces.internal.util.XMLChar类的典型用法代码示例。如果您正苦于以下问题:Java XMLChar类的具体用法?Java XMLChar怎么用?Java XMLChar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XMLChar类属于com.sun.org.apache.xerces.internal.util包,在下文中一共展示了XMLChar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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");
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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] = ' ';
}
}
}