本文整理汇总了Java中org.apache.xerces.xni.XMLString.setValues方法的典型用法代码示例。如果您正苦于以下问题:Java XMLString.setValues方法的具体用法?Java XMLString.setValues怎么用?Java XMLString.setValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xerces.xni.XMLString
的用法示例。
在下文中一共展示了XMLString.setValues方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scanPubidLiteral
import org.apache.xerces.xni.XMLString; //导入方法依赖的package包/类
private boolean scanPubidLiteral(XMLString literal) throws TmxEndEntityException, IOException, RepairableException {
int quote = entityScanner.scanChar();
if (quote != '\'' && quote != '"') {
newRepairableException("QuoteRequiredInPublicID");
return false;
}
fStringBuffer.clear();
// skip leading whitespace
boolean skipSpace = true;
boolean dataok = true;
while (true) {
int c = entityScanner.scanChar();
if (c == ' ' || c == '\n' || c == '\r') {
if (!skipSpace) {
// take the first whitespace as a space and skip the others
fStringBuffer.append(' ');
skipSpace = true;
}
} else if (c == quote) {
if (skipSpace) {
// if we finished on a space let's trim it
fStringBuffer.length--;
}
literal.setValues(fStringBuffer);
break;
} else if (XMLChar.isPubid(c)) {
fStringBuffer.append((char) c);
skipSpace = false;
} else if (c == -1) {
newRepairableException("PublicIDUnterminated");
return false;
} else {
dataok = false;
newRepairableException("InvalidCharInPublicID");
}
}
return dataok;
}
示例2: scanPIData
import org.apache.xerces.xni.XMLString; //导入方法依赖的package包/类
/**
* Scans a processing data. This is needed to handle the situation
* where a document starts with a processing instruction whose
* target name <em>starts with</em> "xml". (e.g. xmlfoo)
*
* <strong>Note:</strong> This method uses fStringBuffer, anything in it
* at the time of calling is lost.
*
* @param target The PI target
* @param data The string to fill in with the data
*/
protected void scanPIData(String target, XMLString data)
throws IOException, XNIException {
// check target
if (target.length() == 3) {
char c0 = Character.toLowerCase(target.charAt(0));
char c1 = Character.toLowerCase(target.charAt(1));
char c2 = Character.toLowerCase(target.charAt(2));
if (c0 == 'x' && c1 == 'm' && c2 == 'l') {
reportFatalError("ReservedPITarget", null);
}
}
// spaces
if (!fEntityScanner.skipSpaces()) {
if (fEntityScanner.skipString("?>")) {
// we found the end, there is no data
data.clear();
return;
}
else {
if(fNamespaces && fEntityScanner.peekChar() == ':') {
fEntityScanner.scanChar();
XMLStringBuffer colonName = new XMLStringBuffer(target);
colonName.append(':');
String str = fEntityScanner.scanName();
if (str != null)
colonName.append(str);
reportFatalError("ColonNotLegalWithNS", new Object[] {colonName.toString()});
fEntityScanner.skipSpaces();
} else {
// if there is data there should be some space
reportFatalError("SpaceRequiredInPI", null);
}
}
}
fStringBuffer.clear();
// data
if (fEntityScanner.scanData("?>", fStringBuffer)) {
do {
int c = fEntityScanner.peekChar();
if (c != -1) {
if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer);
}
else if (isInvalidLiteral(c)) {
reportFatalError("InvalidCharInPI",
new Object[]{Integer.toHexString(c)});
fEntityScanner.scanChar();
}
}
} while (fEntityScanner.scanData("?>", fStringBuffer));
}
data.setValues(fStringBuffer);
}
示例3: scanPubidLiteral
import org.apache.xerces.xni.XMLString; //导入方法依赖的package包/类
/**
* Scans public ID literal.
*
* [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
* [13] PubidChar::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
*
* The returned string is normalized according to the following rule,
* from http://www.w3.org/TR/REC-xml#dt-pubid:
*
* Before a match is attempted, all strings of white space in the public
* identifier must be normalized to single space characters (#x20), and
* leading and trailing white space must be removed.
*
* @param literal The string to fill in with the public ID literal.
* @return True on success.
*
* <strong>Note:</strong> This method uses fStringBuffer, anything in it at
* the time of calling is lost.
*/
protected boolean scanPubidLiteral(XMLString literal)
throws IOException, XNIException
{
int quote = fEntityScanner.scanChar();
if (quote != '\'' && quote != '"') {
reportFatalError("QuoteRequiredInPublicID", null);
return false;
}
fStringBuffer.clear();
// skip leading whitespace
boolean skipSpace = true;
boolean dataok = true;
while (true) {
int c = fEntityScanner.scanChar();
if (c == ' ' || c == '\n' || c == '\r') {
if (!skipSpace) {
// take the first whitespace as a space and skip the others
fStringBuffer.append(' ');
skipSpace = true;
}
}
else if (c == quote) {
if (skipSpace) {
// if we finished on a space let's trim it
fStringBuffer.length--;
}
literal.setValues(fStringBuffer);
break;
}
else if (XMLChar.isPubid(c)) {
fStringBuffer.append((char)c);
skipSpace = false;
}
else if (c == -1) {
reportFatalError("PublicIDUnterminated", null);
return false;
}
else {
dataok = false;
reportFatalError("InvalidCharInPublicID",
new Object[]{Integer.toHexString(c)});
}
}
return dataok;
}
示例4: scanPubidLiteral
import org.apache.xerces.xni.XMLString; //导入方法依赖的package包/类
/**
* Scans public ID literal.
*
* [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
* [13] PubidChar::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
*
* The returned string is normalized according to the following rule,
* from http://www.w3.org/TR/REC-xml#dt-pubid:
*
* Before a match is attempted, all strings of white space in the public
* identifier must be normalized to single space characters (#x20), and
* leading and trailing white space must be removed.
*
* @param literal The string to fill in with the public ID literal.
* @return True on success.
*
* <strong>Note:</strong> This method uses fStringBuffer, anything in it at
* the time of calling is lost.
*/
protected boolean scanPubidLiteral(XMLString literal)
throws IOException, XNIException
{
int quote = fEntityScanner.scanChar();
if (quote != '\'' && quote != '"') {
reportFatalError("QuoteRequiredInPublicID", null);
return false;
}
fStringBuffer.clear();
// skip leading whitespace
boolean skipSpace = true;
boolean dataok = true;
while (true) {
int c = fEntityScanner.scanChar();
// REVISIT: it could really only be \n or 0x20; all else is normalized, no? - neilg
if (c == ' ' || c == '\n' || c == '\r' || c == 0x85 || c == 0x2028) {
if (!skipSpace) {
// take the first whitespace as a space and skip the others
fStringBuffer.append(' ');
skipSpace = true;
}
}
else if (c == quote) {
if (skipSpace) {
// if we finished on a space let's trim it
fStringBuffer.length--;
}
literal.setValues(fStringBuffer);
break;
}
else if (XMLChar.isPubid(c)) {
fStringBuffer.append((char)c);
skipSpace = false;
}
else if (c == -1) {
reportFatalError("PublicIDUnterminated", null);
return false;
}
else {
dataok = false;
reportFatalError("InvalidCharInPublicID",
new Object[]{Integer.toHexString(c)});
}
}
return dataok;
}
示例5: scanPubidLiteral
import org.apache.xerces.xni.XMLString; //导入方法依赖的package包/类
/**
* Scans public ID literal.
*
* [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
* [13] PubidChar::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
*
* The returned string is normalized according to the following rule,
* from http://www.w3.org/TR/REC-xml#dt-pubid:
*
* Before a match is attempted, all strings of white space in the public
* identifier must be normalized to single space characters (#x20), and
* leading and trailing white space must be removed.
*
* @param literal The string to fill in with the public ID literal.
* @return True on success.
*
* <strong>Note:</strong> This method uses fStringBuffer, anything in it at
* the time of calling is lost.
*/
protected boolean scanPubidLiteral(XMLString literal)
throws IOException, XNIException
{
int quote = fEntityScanner.scanChar();
if (quote != '\'' && quote != '"') {
reportFatalError("QuoteRequiredInPublicID", null);
return false;
}
fStringBuffer.clear();
// skip leading whitespace
boolean skipSpace = true;
boolean dataok = true;
while (true) {
int c = fEntityScanner.scanChar();
// REVISIT: none of these except \n and 0x20 should make it past the entity scanner
if (c == ' ' || c == '\n' || c == '\r' || c == 0x85 || c == 0x2028) {
if (!skipSpace) {
// take the first whitespace as a space and skip the others
fStringBuffer.append(' ');
skipSpace = true;
}
}
else if (c == quote) {
if (skipSpace) {
// if we finished on a space let's trim it
fStringBuffer.length--;
}
literal.setValues(fStringBuffer);
break;
}
else if (XMLChar.isPubid(c)) {
fStringBuffer.append((char)c);
skipSpace = false;
}
else if (c == -1) {
reportFatalError("PublicIDUnterminated", null);
return false;
}
else {
dataok = false;
reportFatalError("InvalidCharInPublicID",
new Object[]{Integer.toHexString(c)});
}
}
return dataok;
}
示例6: scanPseudoAttribute
import org.apache.xerces.xni.XMLString; //导入方法依赖的package包/类
private String scanPseudoAttribute(boolean scanningTextDecl, XMLString value) throws IOException,
RepairableException, TmxEndEntityException {
String name = entityScanner.scanName();
if (name.isEmpty()) {
newRepairableException("not found Pseudo Attribute name", entityScanner.getLineNumber(),
entityScanner.getOffsetNumber());
}
entityScanner.skipDeclSpaces();
if (!entityScanner.skipChar('=')) {
newRepairableException("not found '=' when scan Pseudo Attribute", entityScanner.getLineNumber(),
entityScanner.getOffsetNumber());
}
entityScanner.skipDeclSpaces();
int quote = entityScanner.peekChar();
if (quote != '\'' && quote != '"') {
newRepairableException("not found 'quote' when scan Pseudo Attribute", entityScanner.getLineNumber(),
entityScanner.getOffsetNumber());
}
entityScanner.scanChar();
int c = entityScanner.scanLiteral(quote, value);
if (c != quote) {
fStringBuffer2.clear();
do {
fStringBuffer2.append(value);
if (c != -1) {
if (c == '&' || c == '%' || c == '<' || c == ']') {
fStringBuffer2.append((char) entityScanner.scanChar());
}
// REVISIT: Even if you could reliably read non-ASCII chars
// why bother scanning for surrogates here? Only ASCII chars
// match the productions in XMLDecls and TextDecls. -- mrglavas
else if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer2);
} else if (XMLChar.isInvalid(c)) {
entityScanner.scanChar();
// TODO should we report error, or skip this char silence?
// error("Invalid Char in xml declaration : '&#" + Integer.toHexString(c) + "'");
}
}
c = entityScanner.scanLiteral(quote, value);
} while (c != quote);
fStringBuffer2.append(value);
value.setValues(fStringBuffer2);
}
if (!entityScanner.skipChar((char) quote)) {
throw new RepairableException("not found close quote");
}
return name;
}
示例7: scanPIData
import org.apache.xerces.xni.XMLString; //导入方法依赖的package包/类
private void scanPIData(String target, XMLString xs) throws IOException, TmxEndEntityException {
// check target
if (target.length() == 3) {
char c0 = Character.toLowerCase(target.charAt(0));
char c1 = Character.toLowerCase(target.charAt(1));
char c2 = Character.toLowerCase(target.charAt(2));
if (c0 == 'x' && c1 == 'm' && c2 == 'l') {
// TODO 非法命名
return;
}
}
// spaces
if (!entityScanner.skipSpaces()) {
if (entityScanner.skipString("?>")) {
// we found the end, there is no data
xs.clear();
return;
} else {
if (entityScanner.peekChar() == ':') {
entityScanner.scanChar();
XMLStringBuffer colonName = new XMLStringBuffer(target);
colonName.append(':');
String str = entityScanner.scanName();
if (str != null)
colonName.append(str);
// TODO reportFatalError("ColonNotLegalWithNS", new Object[] {colonName.toString()});
entityScanner.skipSpaces();
} else {
// TODO reportFatalError("SpaceRequiredInPI", null);
}
}
}
fStringBuffer.clear();
// data
if (entityScanner.scanData("?>", fStringBuffer)) {
do {
int c = entityScanner.peekChar();
if (c != -1) {
if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer);
} else if (XMLChar.isInvalid(c)) {
// reportFatalError("InvalidCharInPI",
// new Object[]{Integer.toHexString(c)});
entityScanner.scanChar();
}
}
} while (entityScanner.scanData("?>", fStringBuffer));
}
xs.setValues(fStringBuffer);
}
示例8: scanPIData
import org.apache.xerces.xni.XMLString; //导入方法依赖的package包/类
private void scanPIData(String target, XMLString xs) throws IOException {
// check target
if (target.length() == 3) {
char c0 = Character.toLowerCase(target.charAt(0));
char c1 = Character.toLowerCase(target.charAt(1));
char c2 = Character.toLowerCase(target.charAt(2));
if (c0 == 'x' && c1 == 'm' && c2 == 'l') {
// TODO
// reportFatalError("ReservedPITarget", null);
}
}
// spaces
if (!entityScanner.skipSpaces()) {
if (entityScanner.skipString("?>")) {
// we found the end, there is no data
xs.clear();
return;
} else {
if (entityScanner.peekChar() == ':') {
entityScanner.scanChar();
XMLStringBuffer colonName = new XMLStringBuffer(target);
colonName.append(':');
String str = entityScanner.scanName();
if (str != null)
colonName.append(str);
// TODO
// reportFatalError("ColonNotLegalWithNS", new Object[] {colonName.toString()});
entityScanner.skipSpaces();
} else {
// TODO
// if there is data there should be some space
// reportFatalError("SpaceRequiredInPI", null);
}
}
}
fStringBuffer.clear();
// data
if (entityScanner.scanData("?>", fStringBuffer)) {
do {
int c = entityScanner.peekChar();
if (c != -1) {
if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer);
} else if (XMLChar.isInvalid(c)) {
// reportFatalError("InvalidCharInPI",
// new Object[]{Integer.toHexString(c)});
entityScanner.scanChar();
}
}
} while (entityScanner.scanData("?>", fStringBuffer));
}
xs.setValues(fStringBuffer);
}
示例9: scanPseudoAttribute
import org.apache.xerces.xni.XMLString; //导入方法依赖的package包/类
private String scanPseudoAttribute(boolean scanningTextDecl, XMLString value) throws IOException {
String name = entityScanner.scanName();
if (name == null) {
error("not found paseudo attribute");
}
entityScanner.skipDeclSpaces();
if (!entityScanner.skipChar('=')) {
error("not found '='");
}
entityScanner.skipDeclSpaces();
int quote = entityScanner.peekChar();
if (quote != '\'' && quote != '"') {
error("not found quote when scan pseudo attribute");
}
entityScanner.scanChar();
int c = entityScanner.scanLiteral(quote, value);
if (c != quote) {
fStringBuffer2.clear();
do {
fStringBuffer2.append(value);
if (c != -1) {
if (c == '&' || c == '%' || c == '<' || c == ']') {
fStringBuffer2.append((char) entityScanner.scanChar());
}
// REVISIT: Even if you could reliably read non-ASCII chars
// why bother scanning for surrogates here? Only ASCII chars
// match the productions in XMLDecls and TextDecls. -- mrglavas
else if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer2);
} else if (XMLChar.isInvalid(c)) {
String key = scanningTextDecl ? "InvalidCharInTextDecl" : "InvalidCharInXMLDecl";
error("invalid char '&#" + Integer.toHexString(c) + "'");
// reportFatalError(key,
// new Object[] {Integer.toString(c, 16)});
entityScanner.scanChar();
}
}
c = entityScanner.scanLiteral(quote, value);
} while (c != quote);
fStringBuffer2.append(value);
value.setValues(fStringBuffer2);
}
if (!entityScanner.skipChar((char) quote)) {
error("not found close quote");
}
// return
return name;
}