[jdom-interest] Toward beta 9
Bradley S. Huffman
hip at a.cs.okstate.edu
Wed Apr 9 16:16:47 PDT 2003
Elliotte Rusty Harold writes:
> >Verifier check for ProcessingInstruction's setData()? Elliotte can we borrow
> >the check out of XOM's Verifier?
> >
>
> Sure. I officially grant the JDOM permission to republish that check
> under the JDOM license rather than the LGPL.
And here's the patch for Verifier.
*** Verifier.java Wed Apr 9 17:57:04 2003
--- Verifier.new Wed Apr 9 17:56:01 2003
***************
*** 443,448 ****
--- 443,472 ----
return null;
}
+ /**
+ * This will check the supplied data to see if it is legal for use as
+ * <code>{@link ProcessingInstruction}</code> data. Besides checking that
+ * all the characters are allowed in XML, this also checks
+ * that the data does not contain the PI end-string "?>".
+ *
+ * @param data <code>String</code> data to check.
+ * @return <code>String</code> - reason data is illegal, or
+ * <code>null</code> if data is OK.
+ */
+ public static String checkProcessingInstructionData(String data) {
+ // Check basic XML name rules first
+ String reason = checkCharacterData(data);
+
+ if (reason == null) {
+ if (data.indexOf("?>") >= 0) {
+ return "Processing instructions cannot contain " +
+ "the string \"?>\"";
+ }
+ }
+
+ return reason;
+ }
+
/**
* This will check the supplied data to see if it is legal for use as
* JDOM <code>{@link Comment}</code> data.
More information about the jdom-interest
mailing list