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


Java XMLChar.isNameStart方法代码示例

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


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

示例1: scanStartElement

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
protected void scanStartElement() throws IOException, RepairableException, TmxEndEntityException {
	entityScanner.scanQName(elementQName);
	attributes.removeAllAttributes();
	copyQname(elementQName, fCurrentElement);
	do {
		boolean sawSpace = entityScanner.skipSpaces();
		int c = entityScanner.peekChar();
		if (c == '>') {
			entityScanner.scanChar();
			break;
		} else if (c == '/') {
			entityScanner.scanChar();
			if (!entityScanner.skipChar('>')) {
				newRepairableException("[start element] miss '>' after '/'");
			}
			break;
		} else if (!XMLChar.isNameStart(c) || !sawSpace) {
			setScannerState(SCANNER_STATE_CONTENT);
			newRepairableException("[start element] illegal char '" + Integer.toHexString(c) + '\'');
		}
		scanAttribute(attributes);
	} while (true);

	cwriter.writeStartElement(fCurrentElement, attributes);
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:26,代码来源:TmxScanner2.java

示例2: getValidXmlName

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 * Remove invalid XML characters.
 * @param label
 * @return
 */
private static String getValidXmlName(String label) {
	final StringBuilder validNameBuilder = new StringBuilder();
	for(int index=0;index<label.length();index++){
		char c = label.charAt(index);
		if ((index == 0 && XMLChar.isNameStart(c)) || (index != 0 && XMLChar.isName(c))) {
			validNameBuilder.append(c);
		}
	}
	final String validName = validNameBuilder.toString();
	if(validName.isEmpty()){
		return DEFAULT_COLUMN_NAME;
	}
	return validName;
}
 
开发者ID:Neotys-Labs,项目名称:Database-Advanced-Actions,代码行数:20,代码来源:Sqlactionutils.java

示例3: toNCName

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 * Converts a string to valid NCName.
 *
 * @see <a href="https://www.w3.org/TR/1999/WD-xmlschema-2-19990924/#NCName">w3.org</a>
 *
 * @param name the string to convert
 * @return a string which is a valid NCName
 * @throws IllegalArgumentException if there is no way to convert the string to an NCName
 */
public static String toNCName(String name) {
    while (name.length() > 0 && !XMLChar.isNameStart(name.charAt(0))) {
        name = name.substring(1);
    }
    name = toNCNameSecondPart(name);
    if (name.length() == 0) {
        throw new IllegalArgumentException("Unable to convert '" + name + "' to valid NCName.");
    }
    return name;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:20,代码来源:MCRXMLFunctions.java

示例4: purifyName

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/** Purify name. */
protected String purifyName(String name, boolean localpart) {
    if (name == null) {
        return name;
    }
    StringBuffer str = new StringBuffer();
    int length = name.length();
    boolean seenColon = localpart;
    for (int i = 0; i < length; i++) {
        char c = name.charAt(i);
        if (i == 0) {
            if (!XMLChar.isNameStart(c)) {
                str.append("_u"+toHexString(c,4)+"_");
            }
            else {
                str.append(c);
            }
        }
        else {
            if ((fNamespaces && c == ':' && seenColon) || !XMLChar.isName(c)) {
                str.append("_u"+toHexString(c,4)+"_");
            }
            else {
                str.append(c);
            }
            seenColon = seenColon || c == ':';
        }
    }
    return str.toString();
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:31,代码来源:Purifier.java

示例5: isValidNameStartChar

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

示例6: scanStartElement

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
boolean scanStartElement() throws IOException {

		// scan name
		entityScanner.scanQName(fElementQName);

		fCurrentElement = fElementQName;

		if (!scope.isEmpty()) {
			if (scope.lastElement().equals("note") || scope.lastElement().equals("prop")) {
				appendCharacter(encodingCharacter('<'));
				appendCharacter(fElementQName.localpart == null ? "" : fElementQName.localpart);
				setScannerState(SCANNER_STATE_CONTENT);
				return false;
			}
		}

		// scan attributes
		boolean empty = false;
		fAttributes.removeAllAttributes();
		do {
			boolean sawSpace = entityScanner.skipSpaces();
			int c = entityScanner.peekChar();
			if (c == '>') {
				entityScanner.scanChar();
				break;
			} else if (c == '/') {
				entityScanner.scanChar();
				if (!entityScanner.skipChar('>')) {
					// TODO
				}
				empty = true;
				break;
			} else if (!XMLChar.isNameStart(c) || !sawSpace) {
				// Second chance. Check if this character is a high surrogate of a valid name start character.
				// if (!isValidNameStartHighSurrogate(c) || !sawSpace) {
				// }
				error("illegal char '&#" + Integer.toHexString(c) + "'");
				appendCharacter(encodingCharacter(c));
				setScannerState(SCANNER_STATE_CONTENT);
				return false;
			}
			// get the attribute
			scanAttribute(fAttributes);
		} while (true);

		// push element stack
		fCurrentElement = fElementStack.pushElement(fElementQName);

		// if (fElementQName.rawname != null && !fElementQName.rawname.isEmpty()) {
		// writer.write('<');
		// writer.write(fElementQName.rawname);
		// QName qn = new QName();
		//
		// for (int i = 0; i < fAttributes.getLength(); i++) {
		// fAttributes.getName(i, qn);
		// writer.write(' ');
		// writer.write(qn.rawname);
		// writer.write("=");
		// writer.write("\"");
		// writer.write(fAttributes.getValue(i));
		// writer.write("\"");
		// }
		// if (empty) {
		// // 自加减
		// writer.write("/>");
		// fElementStack.popElement(new QName());
		// stack.pop();
		// } else {//有 content
		// writer.write('>');
		// writer.flush();
		// }
		// }

		return empty;
	}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:76,代码来源:TmxScanner.java


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