[jdom-interest] Adding String to Element where String contains an Element in String form

J S ladyslipper98201 at yahoo.com
Tue May 28 14:57:49 PDT 2002


I am trying to use xml in the generation of a jsp.

In jsp you can use custom tags to retrieve dynamic
content.  For example:

---start jsp-----

<%@ taglib uri="/WEB-INF/tld/mycustomtaglib.tld"
prefix="javacustomtag" %>

<html>
Hello <javacustomtag:GetName/>, how are you today
</html>

---end jsp-----

when this is loaded by the appserver/webserver and
displayed to the user the javacustomtag is executed
like
a normal java call and using the id stored in the http
session it retrieve the user's real name from the db
so the user would see upon source view

---- start html ----

<html>
Hello John Smith, how are you today
</html>

---- end html ----

Now if I define my namespace javacustomtag then the
custom tag is output by the XMLOutputter class as 

<javacustomtag:GetName xmlns:help="ignore"/>

which isn't identified by the jsp processor as a valid
custom tag and subsequently the html the user sees is:

---- start html ----

<html>
Hello <javacustomtag:GetName xmlns:help="ignore"/>,
how are you today
</html>

---- end html ----

I hope that clears things up.


--- Alex Rosen <arosen at silverstream.com> wrote:
> JDOM doesn't really support what you're trying to
> do.
> 
> When you set the text of an element to something
> like "3 < 4", it gets
> escaped to "3 &lt; 4" on output because "3 < 4"
> would be illegal XML. It
> happens that "<whatever/>" would not be illegal XML,
> but JDOM doesn't know
> that.
> 
> When you add an Element with a namespace, that
> namespace must be declared,
> because otherwise it's illegal XML.
> 
> I'm not sure why you don't want the namespace
> declaration, because it sounds
> like you're trying out output illegal XML, but you
> might be able to do it by
> subclassing XMLOutputter in some way.
> 
> Alex
> 


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



More information about the jdom-interest mailing list