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


Java XMLChar.isValidName方法代码示例

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


在下文中一共展示了XMLChar.isValidName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCodeCategoryMap

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
private Map<String, DataElementCategory> getCodeCategoryMap( DataElementCategoryCombo categoryCombo )
    throws AdxException
{
    Map<String, DataElementCategory> categoryMap = new HashMap<>();

    List<DataElementCategory> categories = categoryCombo.getCategories();

    for ( DataElementCategory category : categories )
    {
        String categoryCode = category.getCode();

        if ( categoryCode == null || !XMLChar.isValidName( categoryCode ) )
        {
            throw new AdxException(
                "Category code for " + category.getName() + " is missing or invalid: " + categoryCode );
        }

        categoryMap.put( category.getCode(), category );
    }

    return categoryMap;
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:23,代码来源:DefaultAdxDataService.java

示例2: createCategoryMap

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
private Map<String, DataElementCategory> createCategoryMap( DataElementCategoryCombo catcombo )
    throws ADXException
{
    Map<String, DataElementCategory> categoryMap = new HashMap<>();

    List<DataElementCategory> categories = catcombo.getCategories();

    for ( DataElementCategory category : categories )
    {
        String categoryCode = category.getCode();
        
        if ( categoryCode == null || !XMLChar.isValidName( categoryCode ) )
        {
            throw new ADXException( "Category code for " + category.getName() + " is missing or invalid: "
                + categoryCode );
        }
        
        categoryMap.put( category.getCode(), category );
    }

    return categoryMap;
}
 
开发者ID:ehatle,项目名称:AgileAlligators,代码行数:23,代码来源:DefaultADXDataService.java

示例3: isValidStateIdentifier

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 * test if this is a valid state identifier, essentially must be a valid
 * XML attribute name *without* : or . character within.
 */
public static boolean isValidStateIdentifier(String id)
{
    if (id != null)
    {
        for (int i=0; i < id.length(); i++)
        {
            if (!isIdentifierChar(id.charAt(i)))
            {
                return false;
            }
        }
    
        if (!XMLChar.isValidName(id))
        {
            return false;
        }

        return true;
    }
    return false;
}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:26,代码来源:TextParser.java

示例4: validate

import org.apache.xerces.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:AaronZhangL,项目名称:SplitCharater,代码行数:31,代码来源:IDDatatypeValidator.java

示例5: validate

import org.apache.xerces.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:AaronZhangL,项目名称:SplitCharater,代码行数:28,代码来源:IDREFDatatypeValidator.java

示例6: addExplodedCategoryAttributes

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
private void addExplodedCategoryAttributes( DataElementCategoryOptionCombo coc )
    throws AdxException
{
    Map<String, String> categoryAttributes = new HashMap<>();

    if ( !coc.isDefault() )
    {
        for ( DataElementCategory category : coc.getCategoryCombo().getCategories() )
        {
            String categoryCode = category.getCode();
            
            if ( categoryCode == null || !XMLChar.isValidName( categoryCode ) )
            {
                throw new AdxException(
                    "Category code for " + category.getName() + " is missing or invalid: " + categoryCode );
            }

            String catOptCode = category.getCategoryOption( coc ).getCode();
            
            if ( catOptCode == null || catOptCode.isEmpty() )
            {
                throw new AdxException(
                    "CategoryOption code for " + category.getCategoryOption( coc ).getName() + " is missing" );
            }

            categoryAttributes.put( categoryCode, catOptCode );
        }
    }

    categoryOptionMap.put( coc.getId(), categoryAttributes );
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:32,代码来源:AdxDataSetMetadata.java

示例7: isValid

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 * @param text
 * @return
 */
@Override
public boolean isValid( String text )
{
    return ( text.startsWith( "<" ) && text.endsWith( "/>" ) && XMLChar.isValidName( text.substring( 1,
                                                                                                     text.length() - 2 ) ) )
        || ( text.startsWith( "<!--" ) && text.endsWith( "-->" ) );
}
 
开发者ID:RUB-NDS,项目名称:WS-Attacker,代码行数:12,代码来源:XMLElementValidator.java

示例8: isXMLName

import org.apache.xerces.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:AaronZhangL,项目名称:SplitCharater,代码行数:18,代码来源:CoreDocumentImpl.java

示例9: isXMLName

import org.apache.xerces.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:whummer,项目名称:scaleDOM,代码行数:17,代码来源:CoreDocumentImpl.java

示例10: processingInstruction

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/** Processing instruction. */
public void processingInstruction(final String target, final XMLString data,
		final Augmentations augs)
    throws XNIException {
	
	final String s = data.toString();
	if (XMLChar.isValidName(s)) {
        final ProcessingInstruction pi = fDocument.createProcessingInstruction(target, s);
        fCurrentNode.appendChild(pi);
	}
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:12,代码来源:DOMFragmentParser.java

示例11: startElement

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/** Start element. */
public void startElement(QName element, XMLAttributes attrs,
                         Augmentations augs) throws XNIException {
    Element elementNode = fDocument.createElement(element.rawname);
    int count = attrs != null ? attrs.getLength() : 0;
    for (int i = 0; i < count; i++) {
        String aname = attrs.getQName(i);
        String avalue = attrs.getValue(i);
        if (XMLChar.isValidName(aname)) {
        	elementNode.setAttribute(aname, avalue);
        }
    }
    fCurrentNode.appendChild(elementNode);
    fCurrentNode = elementNode;
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:16,代码来源:DOMFragmentParser.java

示例12: encode

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 * Encode a string according to ISO 9075
 * 
 * @param toEncode String
 * @return String
 */
public static String encode(String toEncode)
{
    if ((toEncode == null) || (toEncode.length() == 0))
    {
        return toEncode;
    }
    else if (XMLChar.isValidName(toEncode) && (toEncode.indexOf("_x") == -1) && (toEncode.indexOf(':') == -1))
    {
        return toEncode;
    }
    else
    {
        StringBuilder builder = new StringBuilder(toEncode.length());
        for (int i = 0; i < toEncode.length(); i++)
        {
            char c = toEncode.charAt(i);
            // First requires special test
            if (i == 0)
            {
                if (XMLChar.isNCNameStart(c))
                {
                    // The first character may be the _ at the start of an
                    // encoding pattern
                    if (matchesEncodedPattern(toEncode, i))
                    {
                        // Encode the first _
                        encode('_', builder);
                    }
                    else
                    {
                        // Just append
                        builder.append(c);
                    }
                }
                else
                {
                    // Encode an invalid start character for an XML element
                    // name.
                    encode(c, builder);
                }
            }
            else if (!XMLChar.isNCName(c))
            {
                encode(c, builder);
            }
            else
            {
                if (matchesEncodedPattern(toEncode, i))
                {
                    // '_' must be encoded
                    encode('_', builder);
                }
                else
                {
                    builder.append(c);
                }
            }
        }
        return builder.toString();
    }

}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:69,代码来源:ISO9075.java

示例13: encode

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 * Encode a string according to ISO 9075
 * 
 * @param toEncode
 * @return
 */
public static String encode(String toEncode)
{
    if ((toEncode == null) || (toEncode.length() == 0))
    {
        return toEncode;
    }
    else if (XMLChar.isValidName(toEncode) && (toEncode.indexOf("_x") == -1))
    {
        return toEncode;
    }
    else
    {
        StringBuilder builder = new StringBuilder(toEncode.length());
        for (int i = 0; i < toEncode.length(); i++)
        {
            char c = toEncode.charAt(i);
            // First requires special test
            if (i == 0)
            {
                if (XMLChar.isNCNameStart(c))
                {
                    // The first character may be the _ at the start of an
                    // encoding pattern
                    if (matchesEncodedPattern(toEncode, i))
                    {
                        // Encode the first _
                        encode('_', builder);
                    }
                    else
                    {
                        // Just append
                        builder.append(c);
                    }
                }
                else
                {
                    // Encode an invalid start character for an XML element
                    // name.
                    encode(c, builder);
                }
            }
            else if (!XMLChar.isNCName(c))
            {
                encode(c, builder);
            }
            else
            {
                if (matchesEncodedPattern(toEncode, i))
                {
                    // '_' must be encoded
                    encode('_', builder);
                }
                else
                {
                    builder.append(c);
                }
            }
        }
        return builder.toString();
    }

}
 
开发者ID:xenit-eu,项目名称:move2alf,代码行数:69,代码来源:ISO9075.java

示例14: 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);
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:49,代码来源:BagriXQDataFactory.java

示例15: isValidName

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
protected boolean isValidName(String name) {
    return XMLChar.isValidName(name);
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:4,代码来源:XMLDTDProcessor.java


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