[jdom-interest] Suggestions
Gwenael Treguier
gtreguie at inexware.fr
Tue Dec 19 02:58:57 PST 2000
Hello,
First, I often use CDATA to pass binary data (ie, MD5 encoded password).
To pass this data, I have to encode the bytes in Base64.
Could it be possible to add this feature to JDOM :
public CDATA(byte[] bytes)
{
this(Base64.encode(bytes);
}
Second, but here I am not sure for the XML Specification, when you have a
reference to an entity in a plain text (ie, Dear &name;,), it seems complex to
parse the string to find entity and then do addContent("Dear
").addContent(new Entity(name)).addContent(",");
If you just setText("Dear &name;,"), XMLOuputter gives Dear &name;,
It could be done in XMLOutputter with :
protected String escapeElementEntities(String st) {
case '&' :
+ if (!isEntity(st.substring(i+1, st.length())))
stEntity = "&";
}
public boolean isEntity(String str)
{
int pos = str.indexOf(';');
if (pos != -1 && org.jdom.Verifier.checkElementName(str.substring(0,
pos)) == null)
return true;
return false;
}
Best Regards.
Gwenn.
More information about the jdom-interest
mailing list