[jdom-interest] Embedding HTML in XML

Richard Waters rwaters at marimba.com
Mon Jun 26 13:41:18 PDT 2000

sorry - i didn't realize i was being as vague as i was.  =(

1. i have a textbox in an html form. users type in some text and submit it
to the servlet. For example:

	This is the procedure text I typed in.

2. i create an element, set that text as the content, and add it to my JDOM

	element = new Element("procedure");

3. i save this out to a file using XMLOutputter.output(testplan, savefile)

4. later, this is displayed as html using xalan. basically:
XSLTProcessor.process(savefile, stylesheet, response.getWriter())

now, say i want users to be able to enter some html tags in that text. for

	This is the <i>procedure text</i> I typed in.

i want to <i> tag to be displayed as italics in the html. so what i thought
i would do is parse the above string and create a list with elements like:

	[0] "This is the "
	[1] element = new Element("i");
	    element.setContent("procedure text");
	[2] " I typed in."

then do

	element = new Element("procedure");

then put something in the stylesheet to interpret the <i> elements. what i
was hoping for is not having to parse the strings of text that people
submit. i.e., some way that i can just set the content of an element to
"This is the <i>procedure text</i> I typed in." and have either (1) the <i>
tags _not_ be interpreted by the stylesheet, but interpreted by the browser
as html, or (2) have the <i> tags interpreted by the stylesheet, but still
not have to parse the string and create a list and use setMixedContent().

i shudder at the size of this message now, but hopefully it's clear what i'm
trying to do?

again, any advice would be greatly appreciated,

> -----Original Message-----
> From: Jason Hunter [mailto:jhunter at acm.org]
> Sent: Monday, June 26, 2000 1:08 PM
> To: Richard Waters
> Cc: 'jdom-interest at jdom.org'
> Subject: Re: [jdom-interest] Embedding HTML in XML
> I'd like to help, but you need to be *much* more specific in your
> description for me to provide an alternative solution.
> -jh-
> Richard Waters wrote:
> > 
> > hi all,
> > 
> > i'm trying out a little servlet project with XML - i was 
> previously using
> > the xerces api, but things have become so much easier after 
> switching to
> > jdom. great job!
> > 
> > so maybe someone can help me with this problem: i have 
> users submitting html
> > forms, the content of which is converted into some xml 
> (with XMLOutputter),
> > and later rendered as html (using xalan). i'd like users to 
> be able to enter
> > some html in those textboxes, and have that correctly 
> rendered later.
> > 
> > the only way i came up with to do this is to parse the text 
> submitted with
> > the html forms, create xml elements for the html elements i 
> find, generate a
> > list with these elements and the text, and then use 
> setMixedContent().
> > that's a pretty painful way to do it. since i'm pretty much 
> a novice so far,
> > i'm hoping i'm just failing to see a much easier way to do this.
> > 
> > thanks a lot for any advice you can give,
> > rick
> > _______________________________________________
> > To control your jdom-interest membership:
> > 

More information about the jdom-interest mailing list