Forum Moderators: phranque
A servlet retrieves this field along with others from the database, and puts the content into an XML document (using JDom). It then transforms the XML using XSL documents and results in HTML that we send back to the browser. I think this is pretty normal and it all works.
Now, we want the people who are entering the data in the database to be able to add simple markup, like anchor tags, paragraphs, bold (or strong), italics (or em), etc. We can guaranteee that tags are all closed and otherwise are valid XML.
So if we do nothing, the transformer appears to impolitely remove the tag. Grumble.
If we "pre-escape" the field (turning all "<" into "<" and same with >) and then use disable-output-escaping="yes" as an attribute of the xsl:value-of tag, this works ... sometimes.
It *does* work when we use Xalan from the command line; it *does not* work when we use it from within java with the javax.xml.transform class. When it works, the HTML output contains a reconsitituted tag in the HTML. Joy!
When it fails, the HTML contains a tag <? enable-output-escaping?> at the beginning, the other data including escaped version of the tags (e.g. <b>) and a <? disable-output-escaping?> at the end of the field. A browser actually escapes the &'s as & so HTML source is "&lt;b&gt;". Despair!
In reading posts on various boards, many have castigated disable-output-escaping as a dirty trick/XSLT hack that is only partly supported and would be considered only by impure people of questionable moral terpitude. Since I fall cleanly into this class of person, I would be happy to find a way to make java's transformer do the same as Xalan from the command line. I can believe that the case where it leaves the odd "<?" tags in place is a result of an unsupported operation.
Also, many have said "don't do that". Sadly, I live in a place called "the real world" where pragmatic solutions often outweigh the value of purity :-)
But am I missing something here? Am I just a simple cave man?
All help would be greatly appreciated. I'll aslso happily add all comments about my lack of goodness as a human to an ever growing list which I intend to save and present to the devil as proof of membership. But I digress...