当前位置: 首页>>代码示例>>Java>>正文


Java XMLChar.isValidNCName方法代码示例

本文整理汇总了Java中com.sun.org.apache.xerces.internal.util.XMLChar.isValidNCName方法的典型用法代码示例。如果您正苦于以下问题:Java XMLChar.isValidNCName方法的具体用法?Java XMLChar.isValidNCName怎么用?Java XMLChar.isValidNCName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.org.apache.xerces.internal.util.XMLChar的用法示例。


在下文中一共展示了XMLChar.isValidNCName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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包/类
/**
 * 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:CoreDocumentImpl.java

示例10: 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,代码行数:7,代码来源:IDREFDV.java


注:本文中的com.sun.org.apache.xerces.internal.util.XMLChar.isValidNCName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。