Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/nu/validator/htmlparser/common/TokenHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@ public void startTag(ElementName eltName, HtmlAttributes attributes,
*/
public void comment(@NoLength char[] buf, int start, int length) throws SAXException;

/**
* Receive a processing instruction token. Only emitted when processing
* instructions are enabled on the tokenizer.
*
* @param target
* the processing instruction target
* @param buf
* a buffer holding the data
* @param start the offset into the buffer
* @param length
* the number of code units to read
* @throws SAXException
* if something went wrong
*/
public void processingInstruction(String target, @NoLength char[] buf,
int start, int length) throws SAXException;

/**
* Receive character tokens. This method has the same semantics as the SAX
* method of the same name.
Expand Down
20 changes: 20 additions & 0 deletions src/nu/validator/htmlparser/dom/DOMTreeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,26 @@ protected DOMTreeBuilder(DOMImplementation implementation) {
}
}

@Override protected void appendProcessingInstruction(Element parent,
String target, String data) throws SAXException {
try {
parent.appendChild(
document.createProcessingInstruction(target, data));
} catch (DOMException e) {
fatal(e);
}
}

@Override protected void appendProcessingInstructionToDocument(
String target, String data) throws SAXException {
try {
document.appendChild(
document.createProcessingInstruction(target, data));
} catch (DOMException e) {
fatal(e);
}
}

/**
*
* @see nu.validator.htmlparser.impl.TreeBuilder#createElement(String, String, nu.validator.htmlparser.impl.HtmlAttributes, Object)
Expand Down
20 changes: 20 additions & 0 deletions src/nu/validator/htmlparser/impl/CoalescingTreeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@ protected final void accumulateCharacters(@NoLength char[] buf, int start,

protected abstract void appendCommentToDocument(String comment) throws SAXException;

@Override protected final void appendProcessingInstruction(T parent,
String target, char[] buf, int start, int length)
throws SAXException {
appendProcessingInstruction(parent, target,
new String(buf, start, length));
}

protected abstract void appendProcessingInstruction(T parent, String target,
String data) throws SAXException;

@Override protected final void appendProcessingInstructionToDocument(
String target, char[] buf, int start, int length)
throws SAXException {
appendProcessingInstructionToDocument(target,
new String(buf, start, length));
}

protected abstract void appendProcessingInstructionToDocument(
String target, String data) throws SAXException;

/**
* @see nu.validator.htmlparser.impl.TreeBuilder#insertFosterParentedCharacters(char[], int, int, java.lang.Object, java.lang.Object)
*/
Expand Down
Loading
Loading