本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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();
}
示例5: isValidNameStartChar
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
protected boolean isValidNameStartChar(int value) {
return (XMLChar.isNameStart(value));
}
示例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;
}