Refine search
mVldContent = mValidator.validateElementAndAttributes(); mVldContent = mValidator.validateElementEnd(localName, XmlConsts.ELEM_NO_NS_URI, XmlConsts.ELEM_NO_PREFIX);
protected void writeStartOrEmpty(String prefix, String localName, String nsURI) throws XMLStreamException { checkStartElement(localName, prefix); if (mValidator != null) { mValidator.validateElementStart(localName, nsURI, prefix); } if (mOutputElemPool != null) { SimpleOutputElement newCurr = mOutputElemPool; mOutputElemPool = newCurr.reuseAsChild(mCurrElem, prefix, localName, nsURI); --mPoolSize; mCurrElem = newCurr; } else { mCurrElem = mCurrElem.createChild(prefix, localName, nsURI); } doWriteStartTag(prefix, localName); }
public final void writeTypedElement(AsciiValueEncoder enc, XMLValidator validator, char[] copyBuffer) throws IOException, XMLStreamException { if (mOut == null) { return; } int free = mOutputBufLen - mOutputPtr; if (enc.bufferNeedsFlush(free)) { flush(); } int start = mOutputPtr; while (true) { mOutputPtr = enc.encodeMore(mOutputBuffer, mOutputPtr, mOutputBufLen); // False -> can't be sure it's the whole remaining text validator.validateText(mOutputBuffer, start, mOutputPtr, false); if (enc.isCompleted()) { break; } flush(); start = mOutputPtr; } }
/** * Method called after parsing (but before returning) end element, * to allow for pluggable validators to verify correctness of * the content model for the closing element. * * @return Validation state that should be effective for the parent * element state */ public int validateEndElement() throws XMLStreamException { if (mValidator == null) { // should never be null if we get here return XMLValidator.CONTENT_ALLOW_ANY_TEXT; } int result = mValidator.validateElementEnd (mCurrElement.mLocalName, mCurrElement.mNamespaceURI, mCurrElement.mPrefix); if (mDepth == 1) { // root closing mValidator.validationCompleted(true); } return result; }
public XMLValidator stopValidatingAgainst(XMLValidationSchema schema) throws XMLStreamException { XMLValidator[] results = new XMLValidator[2]; if (ValidatorPair.removeValidator(mValidator, schema, results)) { // found XMLValidator found = results[0]; mValidator = results[1]; found.validationCompleted(false); return found; } return null; }
/** * Validating version of typed write method */ public final void writeTypedElement(AsciiValueEncoder enc, XMLValidator validator, char[] copyBuffer) throws IOException, XMLStreamException { if (mSurrogate != 0) { throwUnpairedSurrogate(); } /* Ok, this gets trickier: can't use efficient direct-to-bytes * encoding since validator won't be able to use it. Instead * have to use temporary copy buffer. */ final int copyBufferLen = copyBuffer.length; // Copy buffer should never be too small, no need to check up front do { int ptr = enc.encodeMore(copyBuffer, 0, copyBufferLen); // False -> can't be sure it's the whole remaining text validator.validateText(copyBuffer, 0, ptr, false); writeRawAscii(copyBuffer, 0, ptr); } while (!enc.isCompleted()); }
if (enc.bufferNeedsFlush(free)) { flush(); mOutputPtr = enc.encodeMore(mOutputBuffer, mOutputPtr, mOutputBufLen); if (enc.isCompleted()) { // yup validator.validateAttribute(localName, nsURI, prefix, mOutputBuffer, start, mOutputPtr); return; validator.validateAttribute(localName, nsURI, prefix, valueStr);
int last = enc.encodeMore(copyBuffer, 0, copyBufferLen); writeRawAscii(copyBuffer, 0, last); if (enc.isCompleted()) { validator.validateAttribute(localName, nsURI, prefix, copyBuffer, 0, last); return; sb.append(copyBuffer, 0, last); do { last = enc.encodeMore(copyBuffer, 0, copyBufferLen); writeRawAscii(copyBuffer, 0, last); sb.append(copyBuffer, 0, last); validator.validateAttribute(localName, nsURI, prefix, valueStr);
public final void validateText(String contents, boolean lastTextSegment) throws XMLStreamException { mValidator.validateText(contents, lastTextSegment); }
/** * Default implementation just indicates it does not know of such * attributes; this because that requires DTD information that only * some implementations have. */ public final int getIdAttributeIndex() { if (mIdAttrIndex >= 0) { return mIdAttrIndex; } return (mValidator == null) ? -1 : mValidator.getIdAttrIndex(); }
/** * Default implementation just indicates it does not know of such * attributes; this because that requires DTD information that only * some implementations have. */ public final int getNotationAttributeIndex() { return (mValidator == null) ? -1 : mValidator.getNotationAttrIndex(); }
/** * @return Schema (DTD, RNG, W3C Schema) based type of the attribute * in specified index */ public final String getAttributeType(int index) { if (index == mIdAttrIndex && index >= 0) { // second check to ensure -1 is not passed return "ID"; } return (mValidator == null) ? WstxInputProperties.UNKNOWN_ATTR_TYPE : mValidator.getAttributeType(index); } }
mValidator.validateAttribute(localName, XmlConsts.ATTR_NO_NS_URI, XmlConsts.ATTR_NO_PREFIX, value);
vld.validateElementStart (mCurrElement.mLocalName, mCurrElement.mNamespaceURI, mCurrElement.mPrefix); return mValidator.validateElementAndAttributes();
public int validateElementEnd(String localName, String uri, String prefix) throws XMLValidationException { int textType1 = mFirst.validateElementEnd(localName, uri, prefix); int textType2 = mSecond.validateElementEnd(localName, uri, prefix); // As with earlier, let's return stricter of the two return (textType1 < textType2) ? textType1 : textType2; }
public static boolean removeValidator(XMLValidator root, XMLValidationSchema schema, XMLValidator[] results) { if (root instanceof ValidatorPair) { return ((ValidatorPair) root).doRemoveValidator(schema, results); } else { if (root.getSchema() == schema) { results[0] = root; results[1] = null; return true; } } return false; }
public int validateElementAndAttributes() throws XMLValidationException { int textType1 = mFirst.validateElementAndAttributes(); int textType2 = mSecond.validateElementAndAttributes(); /* Here, let's choose the stricter (more restrictive) of the two. * Since constants are order from strictest to most lenient, * we'll just take smaller of values */ return (textType1 < textType2) ? textType1 : textType2; }
/** * Returns type of schema that was used to construct this * validator instance. * * @return One of external schema identifier values (such as * {@link XMLValidationSchema#SCHEMA_ID_DTD}). */ public String getSchemaType() { XMLValidationSchema sch = getSchema(); return (sch == null) ? null : sch.getSchemaType(); }
public XMLValidator stopValidatingAgainst(XMLValidator validator) throws XMLStreamException { XMLValidator[] results = new XMLValidator[2]; if (ValidatorPair.removeValidator(mValidator, validator, results)) { // found XMLValidator found = results[0]; mValidator = results[1]; found.validationCompleted(false); return found; } return null; }
/** * Validating version of typed write method */ @Override public final void writeTypedElement(AsciiValueEncoder enc, XMLValidator validator, char[] copyBuffer) throws IOException, XMLStreamException { if (mSurrogate != 0) { throwUnpairedSurrogate(); } /* Ok, this gets trickier: can't use efficient direct-to-bytes * encoding since validator won't be able to use it. Instead * have to use temporary copy buffer. */ final int copyBufferLen = copyBuffer.length; // Copy buffer should never be too small, no need to check up front do { int ptr = enc.encodeMore(copyBuffer, 0, copyBufferLen); // False -> can't be sure it's the whole remaining text validator.validateText(copyBuffer, 0, ptr, false); writeRawAscii(copyBuffer, 0, ptr); } while (!enc.isCompleted()); }