Java Code Examples for org.apache.xerces.xni.XMLString#setValues()
The following examples show how to use
org.apache.xerces.xni.XMLString#setValues() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TmxScanner2.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
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; }
Example 2
Source File: TmxScanner2.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
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; }
Example 3
Source File: TmxScanner2.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
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); }
Example 4
Source File: TmxScanner.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
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); }
Example 5
Source File: TmxScanner.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
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; }