Java Code Examples for org.apache.xerces.xni.XMLString#clear()

The following examples show how to use org.apache.xerces.xni.XMLString#clear() . 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 4 votes vote down vote up
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 2
Source File: TmxScanner.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
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);
	}