本文整理汇总了Java中org.apache.xerces.util.XMLChar.isValidNmtoken方法的典型用法代码示例。如果您正苦于以下问题:Java XMLChar.isValidNmtoken方法的具体用法?Java XMLChar.isValidNmtoken怎么用?Java XMLChar.isValidNmtoken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xerces.util.XMLChar
的用法示例。
在下文中一共展示了XMLChar.isValidNmtoken方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createItemFromString
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
@Override
public XQItem createItemFromString(String value, XQItemType type) throws XQException {
checkState(ex_connection_closed);
if (value == null) {
throw new XQException("value is null");
}
if (type == null) {
type = createAtomicType(XQBASETYPE_STRING);
}
switch (type.getBaseType()) {
case XQBASETYPE_ANYURI:
case XQBASETYPE_NOTATION:
case XQBASETYPE_STRING:
case XQBASETYPE_UNTYPEDATOMIC:
return new BagriXQItem(xqProcessor, type, value);
case XQBASETYPE_ID: if (XMLChar.isValidNCName(value)) {
return new BagriXQItem(xqProcessor, type, value);
}
break;
case XQBASETYPE_NAME: if (XMLChar.isValidName(value)) {
return new BagriXQItem(xqProcessor, type, value);
}
break;
case XQBASETYPE_ENTITY:
case XQBASETYPE_ENTITIES:
case XQBASETYPE_IDREF:
case XQBASETYPE_NCNAME: if (XMLChar.isValidNCName(value)) {
return new BagriXQItem(xqProcessor, type, value);
}
//throw new XQException("can't convert string \"" + value + "\" to type " + type);
break;
case XQBASETYPE_NMTOKEN: if (XMLChar.isValidNmtoken(value)) {
return new BagriXQItem(xqProcessor, type, value);
}
break;
case XQBASETYPE_NORMALIZED_STRING: if (isValidNormalizedString(value)) {
return new BagriXQItem(xqProcessor, type, value);
}
break;
case XQBASETYPE_TOKEN: if (isValidToken(value)) {
return new BagriXQItem(xqProcessor, type, value);
}
break;
}
throw new XQException("wrong string value: " + value + " for type: " + type);
}
示例2: isValidNmtoken
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
protected boolean isValidNmtoken(String nmtoken) {
return XMLChar.isValidNmtoken(nmtoken);
}
示例3: parse
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
public Object parse(String lexicalContent)
throws XSDBuiltinTypeFormatException {
String normalized = normalize(lexicalContent);
if (isFacetDefined(XSDFacets.PATTERN)) {
if (!mPattern.matcher(normalized).matches())
throw new XSDBuiltinTypeFormatException(lexicalContent, this,
"lexical content does not match type pattern: "
+ mPatternStr);
}
if(isFacetDefined(XSDFacets.SPECIAL_PATTERN))
{
if(mSpecialPattern != XSDFacets.SPECIAL_PATTERN_NONE)
{
boolean seenErr = false;
if (mSpecialPattern == XSDFacets.SPECIAL_PATTERN_NMTOKEN) {
// PATTERN "\\c+"
seenErr = !XMLChar.isValidNmtoken(normalized);
}
else if (mSpecialPattern == XSDFacets.SPECIAL_PATTERN_NAME) {
// PATTERN "\\i\\c*"
seenErr = !XMLChar.isValidName(normalized);
}
else if (mSpecialPattern == XSDFacets.SPECIAL_PATTERN_NCNAME) {
// PATTERN "[\\i-[:]][\\c-[:]]*"
seenErr = !XMLChar.isValidNCName(normalized);
}
if (seenErr) {
throw new XSDBuiltinTypeFormatException(normalized, this, "normalized value is not a valid " + SPECIAL_PATTERN_STRING[mSpecialPattern]);
}
}
}
Object actualValue = mValidator.getActualValue(normalized);
checkFacets(normalized, actualValue);
mValidator.checkExtraRules(actualValue);
return actualValue;
}
示例4: validate
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
* Checks that "content" string is valid NMTOKEN 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 {
if (!XMLChar.isValidNmtoken(content)) {
throw new InvalidDatatypeValueException("NMTOKENInvalid", new Object[]{content});
}
}