You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Murray Lang <mu...@metoceanengineers.com> on 2004/05/06 05:21:18 UTC

Adding attributes to an XML element in JSTL

Hi
I've been using the XML tags in JSTL and found them very useful, however 
now I need to add an attribute to an XML element and have hit a brick wall.

I've tried using <c:set> and EL, treating a DOM object as a bean, but the 
DOM interface is implementation-dependent and my implementation (xerces) 
doesn't lend itself to adding attributes with the simple EL view of bean 
properties.

It seems to me that <x:set> needs to have a "target"attribute along the 
same lines as <c:set>, but accepting an XPath expression.
eg
	<x:set select="12345" 
target="$myRoot//myElement[position()=0]/@myAttribute" />
where:
	- select can be either an XPath expression or an immediate value.
	- if @myAttribute doesn't currently exist in the element then it is created.

Does this make sense?
Is there a simple, portable, way of achieving this using JSTL as it stands? 
(Using <c:set> is not portable due to DOM being implementation dependent).

Thanks
Murray


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by Murray Lang <mu...@metoceanengineers.com>.
Yes.
Basically, my task would have been a doddle if <x:set> had a "varDom" (or 
maybe it should be "varW3c") attribute the same as <x:parse>. Then I could 
have manipulated the XML in a portable way.

Murray

At 04:39 AM 13/05/2004, you wrote:
>Murray,
>
>>OK, so I can settle (grudgingly) for writing/finding another XML tag
>>library that can actually manipulate XML. The shame of it is that if
>>I want to also use the JSTL tags (which I like very much) then I'll
>>have to duplicate all of my XPath expressions and context variables
>>for the new tags because the only JSTL tag that exposes a standard
>>w3c.dom.Document is <x:parse>. If only <x:set> and <x:forEach> had a
>>"varDom" attribute, then the JSTL could be easily complemented by
>>other (naughty) XML-based tag libraries.
>
>When an XPath expression is evaluated, the result is mapped to
>a Java type according to the following rules:
>
>XPath       Java
>-----       ----
>boolean  -> java.lang.Boolean
>number   -> java.lang.Number
>string   -> java.lang.String
>node-set -> Type usable by JSTL XML-manipulation
>            tags in the same JSTL implementation. The
>            specific Java type representing node-sets
>            may thus vary by implementation.
>
>If I understand you correctly, given that the  only mapping that's not
>specified is 'node-set',  you'd want the  capability  to  force  the
>mapping  of an  XPath node-set to  be  of a  specific  type, e.g.
>org.w3c.dom.NodeList. Correct?
>
>    -- Pierre
>
>Murray Lang wrote:
>
>>Are you saying that if I want to get user input (from a <form>) into XML 
>>for a back-end system then JSP is not suitable?. I can't accept that.
>>I could use Struts (which seems like overkill), or write a tag library 
>>that took all of the <form> values and spat out w3c.dom.Document, but any 
>>changes to the input options would then require that a bean and its JAR 
>>be recompiled and  re-deployed. Using a generic XML Tag library to put 
>>the values into an XML tree would be more maintainable.
>>OK, so I can settle (grudgingly) for writing/finding another XML tag 
>>library that can actually manipulate XML. The shame of it is that if I 
>>want to also use the JSTL tags (which I like very much) then I'll have to 
>>duplicate all of my XPath expressions and context variables for the new 
>>tags because the only JSTL tag that exposes a standard w3c.dom.Document 
>>is <x:parse>. If only <x:set> and <x:forEach> had a "varDom" attribute, 
>>then the JSTL could be easily complemented by other (naughty) XML-based 
>>tag libraries.
>>Murray
>>
>>At 04:24 PM 7/05/2004, you wrote:
>>
>>>hey, come on, this is just a jsp - you would not really want to litter 
>>>your presentation layer with all sorts of business-logic: if jstl goes 
>>>down this path, it will end up being a crippled version of cfml or even 
>>>worse asp...
>>>
>>>Murray Lang wrote:
>>>
>>>>Actually, what the Sun JSTL web page says is:
>>>>"JSTL has support for common, structural tasks such as iteration and 
>>>>conditionals, tags for manipulating XML documents, internationalization 
>>>>tags, and SQL tags."
>>>>"manipulating"!
>>>>Anyway, I take your point that it is outside the scope of the JSTL XML 
>>>>tags at the moment. It seems to me a rather arbitrary limitation 
>>>>though. As the JSTL documentation says: "...when companies cooperate 
>>>>over the web, XML is the data format of choice for exchanging 
>>>>information.". IMHO being unable to manipulate XML is odd for a 
>>>>technology that has such language in it's documentation. An exchange of 
>>>>information involves two parties, one at least of which has created some XML.
>>>>Thanks for the JXPath link. What worries me about it though is that it 
>>>>won't necessarily use the same DOM implementation as JSTL 
>>>>implementation, meaning that they won't work with each other. It seems 
>>>>a shame if this is the case. I'll look at it though - it might not be that bad.
>>>>Cheers
>>>>Murray
>>>>
>>>>At 01:33 AM 7/05/2004, you wrote:
>>>>
>>>>>This is outside the scope of the taglibrary, JSTL xml taglibrary is 
>>>>>for presentation of xml content, not for its manipulation. I recommend 
>>>>>looking into a package such as JXPath to accomplish manipulation of 
>>>>>the content of a DOM object. the nice thing is that JXPath can be 
>>>>>scripted into a JSP, Servlet or Struts Action, which gives you the 
>>>>>fredom to move it out of the Presentation layer (where you probibly 
>>>>>shouldn't be placing such logic).
>>>>>
>>>>>http://jakarta.apache.org/commons/jxpath/
>>>>>
>>>>>Good Luck
>>>>>-Mark
>>>>>
>>>>>Murray Lang wrote:
>>>>>
>>>>>>Hi
>>>>>>I've been using the XML tags in JSTL and found them very useful, 
>>>>>>however now I need to add an attribute to an XML element and have hit 
>>>>>>a brick wall.
>>>>>>
>>>>>>I've tried using <c:set> and EL, treating a DOM object as a bean, but 
>>>>>>the DOM interface is implementation-dependent and my implementation 
>>>>>>(xerces) doesn't lend itself to adding attributes with the simple EL 
>>>>>>view of bean properties.
>>>>>>
>>>>>>It seems to me that <x:set> needs to have a "target"attribute along 
>>>>>>the same lines as <c:set>, but accepting an XPath expression.
>>>>>>eg
>>>>>>     <x:set select="12345" 
>>>>>> target="$myRoot//myElement[position()=0]/@myAttribute" />
>>>>>>where:
>>>>>>     - select can be either an XPath expression or an immediate value.
>>>>>>     - if @myAttribute doesn't currently exist in the element then it 
>>>>>> is created.
>>>>>>
>>>>>>Does this make sense?
>>>>>>Is there a simple, portable, way of achieving this using JSTL as it 
>>>>>>stands? (Using <c:set> is not portable due to DOM being 
>>>>>>implementation dependent).
>>>>>>
>>>>>>Thanks
>>>>>>Murray
>>>>>>
>>>>>>
>>>>>>---------------------------------------------------------------------
>>>>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>---------------------------------------------------------------------
>>>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>>
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>
>>>
>>>--
>>>Stefan Frank
>>>iBioS - Intelligent BioInformatics Systems
>>>http://www.dkfz-heidelberg.de/ibios
>>>DKFZ - German Cancer Research Center
>>>Im Neuenheimer Feld 580
>>>69120 Heidelberg
>>>Tel.: +49 (0) 6221 42-3612
>>>Mail: s.frank@dkfz-heidelberg.de
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by Murray Lang <mu...@metoceanengineers.com>.
Struts helps if I re-start the whole application from scratch. It's not a 
bad fit for what I'm doing, but it seemed to me when I was initially 
looking at the options that JSTL would be sufficient. It didn't seem 
sensible to complicate a fairly simple application with all the Struts 
fiddly bits.

Actually, I'm giving XForms one more shot first. I might just be able to 
make Chiba fit in with my JSP stuff. Just love punishment.

Murray

At 08:45 PM 24/05/2004, you wrote:
>I'm not sure how Struts is going to help you here. IIRC, you wanted to 
>update a
>cached document with values from request parameters, or at least represent the
>request parameters as a document, is that right? If so, it seems like the 
>place
>to do that sort of thing would be in a Servlet Filter. Depending on what you'd
>like to do (update existing DOM, create DOM from parameters, create XML text
>from parameters), there are probably a number of different ways to slice it.
>
>Quoting Murray Lang <mu...@metoceanengineers.com>:
>
> > Anyway, it seems to me that if JSTL is inconsistent by not allowing the 
> XML
> > to be modified. After all, the <c:set> tag has a "target" attribute. If
> > it's OK for <c:set> then why is it not OK for <x:set>?
> > For example:
> >          <x:set target="$myXML/myElement/@myAttribute" 
> select="SomeValue" />
> >
> > Never mind. The fact is that I can't do this and my JSP was getting messy
> > enough anyway without putting in extra workarounds to modify my XML data.
> > I'm going to bite the bullet now and try Struts (I tried XForms but it was
> > a waste of time due to limits in the implementations).
> >
> > Murray
>
>--
>Kris Schneider <ma...@dotech.com>
>D.O.Tech       <http://www.dotech.com/>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Currencies in other Locale than selected Bundle

Posted by Evgeny Gesin <ev...@yahoo.com>.
The user can select a language on web site. Selected
locale is stored in the user session and used to read
text from corresponded resource bundle. Currency is
diplayed as follows

<jsp:useBean id="locale" scope="session"    
class="java.util.Locale" />
<fmt:setLocale value="<%= locale %>" />
<fmt:bundle basename="bundle">

<P><fmt:formatNumber value="<%= new
Double(line.getTotal()) %>" type="currency" /></P>

</fmt:bundle>

I need to display content of a site in Russian, but
product prices in Israeli Shequels, not in Russian
Rubels (as the code above does). Could you post a code
sample how to display currencies in other locale than
the rest of content.

Evgeny
Javadesk


	
		
__________________________________
Do you Yahoo!?
Yahoo! Domains � Claim yours for only $14.70/year
http://smallbusiness.promotions.yahoo.com/offer 

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by Kris Schneider <kr...@dotech.com>.
I'm not sure how Struts is going to help you here. IIRC, you wanted to update a
cached document with values from request parameters, or at least represent the
request parameters as a document, is that right? If so, it seems like the place
to do that sort of thing would be in a Servlet Filter. Depending on what you'd
like to do (update existing DOM, create DOM from parameters, create XML text
from parameters), there are probably a number of different ways to slice it.

Quoting Murray Lang <mu...@metoceanengineers.com>:

> Anyway, it seems to me that if JSTL is inconsistent by not allowing the XML 
> to be modified. After all, the <c:set> tag has a "target" attribute. If 
> it's OK for <c:set> then why is it not OK for <x:set>?
> For example:
>          <x:set target="$myXML/myElement/@myAttribute" select="SomeValue" />
> 
> Never mind. The fact is that I can't do this and my JSP was getting messy 
> enough anyway without putting in extra workarounds to modify my XML data.
> I'm going to bite the bullet now and try Struts (I tried XForms but it was 
> a waste of time due to limits in the implementations).
> 
> Murray

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by Murray Lang <mu...@metoceanengineers.com>.
Anyway, it seems to me that if JSTL is inconsistent by not allowing the XML 
to be modified. After all, the <c:set> tag has a "target" attribute. If 
it's OK for <c:set> then why is it not OK for <x:set>?
For example:
         <x:set target="$myXML/myElement/@myAttribute" select="SomeValue" />

Never mind. The fact is that I can't do this and my JSP was getting messy 
enough anyway without putting in extra workarounds to modify my XML data.
I'm going to bite the bullet now and try Struts (I tried XForms but it was 
a waste of time due to limits in the implementations).

Murray

At 10:28 AM 13/05/2004, you wrote:
>Thanks Pierre,
>
>>Where I don't follow is when you say that "any changes to the input 
>>options would then require that a bean and its JAR be recompiled 
>>and  re-deployed."
>
>Firstly I should point out that I am working on a prototype ("hacking" 
>might be a little more honest), to try to clarify in my own head and in 
>the head of my client how the application will look.
>My understanding of Struts (I haven't used it yet but I'm thinking maybe I 
>should) is that a form needs a corresponding "ActionForm" bean, with 
>fields corresponding to the form elements. So if the form changes then the 
>bean must change. If I was to write a custom tag (also a bean) to create 
>the XML from the form values then the tag library might also need 
>rebuilding with changes to form contents. I know this makes me sound lazy 
>and such a scenario isn't really that bad, but if only JSTL could 
>manipulate XML then the job could be done with a single line of JSP (per 
>value).
>
>>Could you provide more specific details on your use-case?
>
>- A system that performs hydrodynamics calculations accepts its numerous 
>input parameters in XML. The program is a work in progress and the 
>parameters will be refined and enhanced over time.
>- Previously performed calculations (parameters and results) can be 
>retrieved from the system in XML.
>- The system is accessed in JSP through a tag library.
>- The JSP form for inputting the parameters can be initialised with values 
>from a previous calculation. The JSTL XML tag library is used for this.
>- Values from the form need to go into the same XML format to pass to the 
>system's tag library for calculation/storage.
>
>So the DOM object is sitting there as a context variable and I've got all 
>of the parameters singled out - but I can't put new values back in. I have 
>to go through the rigmorol of creating a new DOM tree with the parameters. 
>Note also that to refresh the form with the new XML means that it will 
>have to replace the original DOM context variable. Seems wasteful to me.
>
>XForms is another approach I'm looking at, but all of these technologies 
>take time to master and, as much as I'd love to, I can't spend forever 
>messing around with them.
>
>Murray
>
>
>At 05:17 AM 13/05/2004, you wrote:
>>Murray,
>>
>>>Are you saying that if I want to get user input (from a <form>) into XML 
>>>for a back-end system then JSP is not suitable?. I can't accept that.
>>>I could use Struts (which seems like overkill), or write a tag library 
>>>that took all of the <form> values and spat out w3c.dom.Document, but 
>>>any changes to the input options would then require that a bean and its 
>>>JAR be recompiled and  re-deployed. Using a generic XML Tag library to 
>>>put the values into an XML tree would be more maintainable.
>>
>>I'm always interested in hearing more about XML-related use cases.
>>
>>If I understand you well, you want a JSP page (that is the target of a
>>form submission) to create an XML document out of all the request
>>parameters it receives. Correct?
>>
>>Where I don't follow is when you say that "any changes to the input 
>>options would then require that a bean and its JAR be recompiled 
>>and  re-deployed."
>>
>>Could you provide more specific details on your use-case?
>>I'd like to dig a little more and see how best your use-case should
>>be handled (given the constraints of your environment).
>>This thread has already generated some great feedback from Mark and Kris,
>>and I'm sure we can milk even more interesting comments from it...
>>
>>    -- Pierre
>>
>>Murray Lang wrote:
>>
>>>Are you saying that if I want to get user input (from a <form>) into XML 
>>>for a back-end system then JSP is not suitable?. I can't accept that.
>>>I could use Struts (which seems like overkill), or write a tag library 
>>>that took all of the <form> values and spat out w3c.dom.Document, but 
>>>any changes to the input options would then require that a bean and its 
>>>JAR be recompiled and  re-deployed. Using a generic XML Tag library to 
>>>put the values into an XML tree would be more maintainable.
>>>OK, so I can settle (grudgingly) for writing/finding another XML tag 
>>>library that can actually manipulate XML. The shame of it is that if I 
>>>want to also use the JSTL tags (which I like very much) then I'll have 
>>>to duplicate all of my XPath expressions and context variables for the 
>>>new tags because the only JSTL tag that exposes a standard 
>>>w3c.dom.Document is <x:parse>. If only <x:set> and <x:forEach> had a 
>>>"varDom" attribute, then the JSTL could be easily complemented by other 
>>>(naughty) XML-based tag libraries.
>>>Murray
>>>
>>>At 04:24 PM 7/05/2004, you wrote:
>>>
>>>>hey, come on, this is just a jsp - you would not really want to litter 
>>>>your presentation layer with all sorts of business-logic: if jstl goes 
>>>>down this path, it will end up being a crippled version of cfml or even 
>>>>worse asp...
>>>>
>>>>Murray Lang wrote:
>>>>
>>>>>Actually, what the Sun JSTL web page says is:
>>>>>"JSTL has support for common, structural tasks such as iteration and 
>>>>>conditionals, tags for manipulating XML documents, 
>>>>>internationalization tags, and SQL tags."
>>>>>"manipulating"!
>>>>>Anyway, I take your point that it is outside the scope of the JSTL XML 
>>>>>tags at the moment. It seems to me a rather arbitrary limitation 
>>>>>though. As the JSTL documentation says: "...when companies cooperate 
>>>>>over the web, XML is the data format of choice for exchanging 
>>>>>information.". IMHO being unable to manipulate XML is odd for a 
>>>>>technology that has such language in it's documentation. An exchange 
>>>>>of information involves two parties, one at least of which has created 
>>>>>some XML.
>>>>>Thanks for the JXPath link. What worries me about it though is that it 
>>>>>won't necessarily use the same DOM implementation as JSTL 
>>>>>implementation, meaning that they won't work with each other. It seems 
>>>>>a shame if this is the case. I'll look at it though - it might not be that bad.
>>>>>Cheers
>>>>>Murray
>>>>>
>>>>>At 01:33 AM 7/05/2004, you wrote:
>>>>>
>>>>>>This is outside the scope of the taglibrary, JSTL xml taglibrary is 
>>>>>>for presentation of xml content, not for its manipulation. I 
>>>>>>recommend looking into a package such as JXPath to accomplish 
>>>>>>manipulation of the content of a DOM object. the nice thing is that 
>>>>>>JXPath can be scripted into a JSP, Servlet or Struts Action, which 
>>>>>>gives you the fredom to move it out of the Presentation layer (where 
>>>>>>you probibly shouldn't be placing such logic).
>>>>>>
>>>>>>http://jakarta.apache.org/commons/jxpath/
>>>>>>
>>>>>>Good Luck
>>>>>>-Mark
>>>>>>
>>>>>>Murray Lang wrote:
>>>>>>
>>>>>>>Hi
>>>>>>>I've been using the XML tags in JSTL and found them very useful, 
>>>>>>>however now I need to add an attribute to an XML element and have 
>>>>>>>hit a brick wall.
>>>>>>>
>>>>>>>I've tried using <c:set> and EL, treating a DOM object as a bean, 
>>>>>>>but the DOM interface is implementation-dependent and my 
>>>>>>>implementation (xerces) doesn't lend itself to adding attributes 
>>>>>>>with the simple EL view of bean properties.
>>>>>>>
>>>>>>>It seems to me that <x:set> needs to have a "target"attribute along 
>>>>>>>the same lines as <c:set>, but accepting an XPath expression.
>>>>>>>eg
>>>>>>>     <x:set select="12345" 
>>>>>>> target="$myRoot//myElement[position()=0]/@myAttribute" />
>>>>>>>where:
>>>>>>>     - select can be either an XPath expression or an immediate value.
>>>>>>>     - if @myAttribute doesn't currently exist in the element then 
>>>>>>> it is created.
>>>>>>>
>>>>>>>Does this make sense?
>>>>>>>Is there a simple, portable, way of achieving this using JSTL as it 
>>>>>>>stands? (Using <c:set> is not portable due to DOM being 
>>>>>>>implementation dependent).
>>>>>>>
>>>>>>>Thanks
>>>>>>>Murray
>>>>>>>
>>>>>>>
>>>>>>>---------------------------------------------------------------------
>>>>>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>>>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>---------------------------------------------------------------------
>>>>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>>>
>>>>>
>>>>>
>>>>>---------------------------------------------------------------------
>>>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>>
>>>>
>>>>--
>>>>Stefan Frank
>>>>iBioS - Intelligent BioInformatics Systems
>>>>http://www.dkfz-heidelberg.de/ibios
>>>>DKFZ - German Cancer Research Center
>>>>Im Neuenheimer Feld 580
>>>>69120 Heidelberg
>>>>Tel.: +49 (0) 6221 42-3612
>>>>Mail: s.frank@dkfz-heidelberg.de
>>>>
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by Murray Lang <mu...@metoceanengineers.com>.
Thanks Pierre,

>Where I don't follow is when you say that "any changes to the input 
>options would then require that a bean and its JAR be recompiled 
>and  re-deployed."

Firstly I should point out that I am working on a prototype ("hacking" 
might be a little more honest), to try to clarify in my own head and in the 
head of my client how the application will look.
My understanding of Struts (I haven't used it yet but I'm thinking maybe I 
should) is that a form needs a corresponding "ActionForm" bean, with fields 
corresponding to the form elements. So if the form changes then the bean 
must change. If I was to write a custom tag (also a bean) to create the XML 
from the form values then the tag library might also need rebuilding with 
changes to form contents. I know this makes me sound lazy and such a 
scenario isn't really that bad, but if only JSTL could manipulate XML then 
the job could be done with a single line of JSP (per value).

>Could you provide more specific details on your use-case?

- A system that performs hydrodynamics calculations accepts its numerous 
input parameters in XML. The program is a work in progress and the 
parameters will be refined and enhanced over time.
- Previously performed calculations (parameters and results) can be 
retrieved from the system in XML.
- The system is accessed in JSP through a tag library.
- The JSP form for inputting the parameters can be initialised with values 
from a previous calculation. The JSTL XML tag library is used for this.
- Values from the form need to go into the same XML format to pass to the 
system's tag library for calculation/storage.

So the DOM object is sitting there as a context variable and I've got all 
of the parameters singled out - but I can't put new values back in. I have 
to go through the rigmorol of creating a new DOM tree with the parameters. 
Note also that to refresh the form with the new XML means that it will have 
to replace the original DOM context variable. Seems wasteful to me.

XForms is another approach I'm looking at, but all of these technologies 
take time to master and, as much as I'd love to, I can't spend forever 
messing around with them.

Murray


At 05:17 AM 13/05/2004, you wrote:
>Murray,
>
>>Are you saying that if I want to get user input (from a <form>) into XML 
>>for a back-end system then JSP is not suitable?. I can't accept that.
>>I could use Struts (which seems like overkill), or write a tag library 
>>that took all of the <form> values and spat out w3c.dom.Document, but any 
>>changes to the input options would then require that a bean and its JAR 
>>be recompiled and  re-deployed. Using a generic XML Tag library to put 
>>the values into an XML tree would be more maintainable.
>
>I'm always interested in hearing more about XML-related use cases.
>
>If I understand you well, you want a JSP page (that is the target of a
>form submission) to create an XML document out of all the request
>parameters it receives. Correct?
>
>Where I don't follow is when you say that "any changes to the input 
>options would then require that a bean and its JAR be recompiled 
>and  re-deployed."
>
>Could you provide more specific details on your use-case?
>I'd like to dig a little more and see how best your use-case should
>be handled (given the constraints of your environment).
>This thread has already generated some great feedback from Mark and Kris,
>and I'm sure we can milk even more interesting comments from it...
>
>    -- Pierre
>
>Murray Lang wrote:
>
>>Are you saying that if I want to get user input (from a <form>) into XML 
>>for a back-end system then JSP is not suitable?. I can't accept that.
>>I could use Struts (which seems like overkill), or write a tag library 
>>that took all of the <form> values and spat out w3c.dom.Document, but any 
>>changes to the input options would then require that a bean and its JAR 
>>be recompiled and  re-deployed. Using a generic XML Tag library to put 
>>the values into an XML tree would be more maintainable.
>>OK, so I can settle (grudgingly) for writing/finding another XML tag 
>>library that can actually manipulate XML. The shame of it is that if I 
>>want to also use the JSTL tags (which I like very much) then I'll have to 
>>duplicate all of my XPath expressions and context variables for the new 
>>tags because the only JSTL tag that exposes a standard w3c.dom.Document 
>>is <x:parse>. If only <x:set> and <x:forEach> had a "varDom" attribute, 
>>then the JSTL could be easily complemented by other (naughty) XML-based 
>>tag libraries.
>>Murray
>>
>>At 04:24 PM 7/05/2004, you wrote:
>>
>>>hey, come on, this is just a jsp - you would not really want to litter 
>>>your presentation layer with all sorts of business-logic: if jstl goes 
>>>down this path, it will end up being a crippled version of cfml or even 
>>>worse asp...
>>>
>>>Murray Lang wrote:
>>>
>>>>Actually, what the Sun JSTL web page says is:
>>>>"JSTL has support for common, structural tasks such as iteration and 
>>>>conditionals, tags for manipulating XML documents, internationalization 
>>>>tags, and SQL tags."
>>>>"manipulating"!
>>>>Anyway, I take your point that it is outside the scope of the JSTL XML 
>>>>tags at the moment. It seems to me a rather arbitrary limitation 
>>>>though. As the JSTL documentation says: "...when companies cooperate 
>>>>over the web, XML is the data format of choice for exchanging 
>>>>information.". IMHO being unable to manipulate XML is odd for a 
>>>>technology that has such language in it's documentation. An exchange of 
>>>>information involves two parties, one at least of which has created some XML.
>>>>Thanks for the JXPath link. What worries me about it though is that it 
>>>>won't necessarily use the same DOM implementation as JSTL 
>>>>implementation, meaning that they won't work with each other. It seems 
>>>>a shame if this is the case. I'll look at it though - it might not be that bad.
>>>>Cheers
>>>>Murray
>>>>
>>>>At 01:33 AM 7/05/2004, you wrote:
>>>>
>>>>>This is outside the scope of the taglibrary, JSTL xml taglibrary is 
>>>>>for presentation of xml content, not for its manipulation. I recommend 
>>>>>looking into a package such as JXPath to accomplish manipulation of 
>>>>>the content of a DOM object. the nice thing is that JXPath can be 
>>>>>scripted into a JSP, Servlet or Struts Action, which gives you the 
>>>>>fredom to move it out of the Presentation layer (where you probibly 
>>>>>shouldn't be placing such logic).
>>>>>
>>>>>http://jakarta.apache.org/commons/jxpath/
>>>>>
>>>>>Good Luck
>>>>>-Mark
>>>>>
>>>>>Murray Lang wrote:
>>>>>
>>>>>>Hi
>>>>>>I've been using the XML tags in JSTL and found them very useful, 
>>>>>>however now I need to add an attribute to an XML element and have hit 
>>>>>>a brick wall.
>>>>>>
>>>>>>I've tried using <c:set> and EL, treating a DOM object as a bean, but 
>>>>>>the DOM interface is implementation-dependent and my implementation 
>>>>>>(xerces) doesn't lend itself to adding attributes with the simple EL 
>>>>>>view of bean properties.
>>>>>>
>>>>>>It seems to me that <x:set> needs to have a "target"attribute along 
>>>>>>the same lines as <c:set>, but accepting an XPath expression.
>>>>>>eg
>>>>>>     <x:set select="12345" 
>>>>>> target="$myRoot//myElement[position()=0]/@myAttribute" />
>>>>>>where:
>>>>>>     - select can be either an XPath expression or an immediate value.
>>>>>>     - if @myAttribute doesn't currently exist in the element then it 
>>>>>> is created.
>>>>>>
>>>>>>Does this make sense?
>>>>>>Is there a simple, portable, way of achieving this using JSTL as it 
>>>>>>stands? (Using <c:set> is not portable due to DOM being 
>>>>>>implementation dependent).
>>>>>>
>>>>>>Thanks
>>>>>>Murray
>>>>>>
>>>>>>
>>>>>>---------------------------------------------------------------------
>>>>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>---------------------------------------------------------------------
>>>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>>
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>
>>>
>>>--
>>>Stefan Frank
>>>iBioS - Intelligent BioInformatics Systems
>>>http://www.dkfz-heidelberg.de/ibios
>>>DKFZ - German Cancer Research Center
>>>Im Neuenheimer Feld 580
>>>69120 Heidelberg
>>>Tel.: +49 (0) 6221 42-3612
>>>Mail: s.frank@dkfz-heidelberg.de
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by Pierre Delisle <Pi...@Sun.COM>.
Murray,

> Are you saying that if I want to get user input (from a <form>) into XML 
> for a back-end system then JSP is not suitable?. I can't accept that.
> 
> I could use Struts (which seems like overkill), or write a tag library 
> that took all of the <form> values and spat out w3c.dom.Document, but 
> any changes to the input options would then require that a bean and its 
> JAR be recompiled and  re-deployed. Using a generic XML Tag library to 
> put the values into an XML tree would be more maintainable.

I'm always interested in hearing more about XML-related use cases.

If I understand you well, you want a JSP page (that is the target of a
form submission) to create an XML document out of all the request
parameters it receives. Correct?

Where I don't follow is when you say that 
"any changes to the input options would then require that a bean and its 
JAR be recompiled and  re-deployed."

Could you provide more specific details on your use-case?
I'd like to dig a little more and see how best your use-case should
be handled (given the constraints of your environment).
This thread has already generated some great feedback from Mark and Kris,
and I'm sure we can milk even more interesting comments from it...

    -- Pierre 


Murray Lang wrote:

> Are you saying that if I want to get user input (from a <form>) into XML 
> for a back-end system then JSP is not suitable?. I can't accept that.
> 
> I could use Struts (which seems like overkill), or write a tag library 
> that took all of the <form> values and spat out w3c.dom.Document, but 
> any changes to the input options would then require that a bean and its 
> JAR be recompiled and  re-deployed. Using a generic XML Tag library to 
> put the values into an XML tree would be more maintainable.
> 
> OK, so I can settle (grudgingly) for writing/finding another XML tag 
> library that can actually manipulate XML. The shame of it is that if I 
> want to also use the JSTL tags (which I like very much) then I'll have 
> to duplicate all of my XPath expressions and context variables for the 
> new tags because the only JSTL tag that exposes a standard 
> w3c.dom.Document is <x:parse>. If only <x:set> and <x:forEach> had a 
> "varDom" attribute, then the JSTL could be easily complemented by other 
> (naughty) XML-based tag libraries.
> 
> Murray
> 
> 
> At 04:24 PM 7/05/2004, you wrote:
> 
>> hey, come on, this is just a jsp - you would not really want to litter 
>> your presentation layer with all sorts of business-logic: if jstl goes 
>> down this path, it will end up being a crippled version of cfml or 
>> even worse asp...
>>
>> Murray Lang wrote:
>>
>>> Actually, what the Sun JSTL web page says is:
>>> "JSTL has support for common, structural tasks such as iteration and 
>>> conditionals, tags for manipulating XML documents, 
>>> internationalization tags, and SQL tags."
>>> "manipulating"!
>>> Anyway, I take your point that it is outside the scope of the JSTL 
>>> XML tags at the moment. It seems to me a rather arbitrary limitation 
>>> though. As the JSTL documentation says: "...when companies cooperate 
>>> over the web, XML is the data format of choice for exchanging 
>>> information.". IMHO being unable to manipulate XML is odd for a 
>>> technology that has such language in it's documentation. An exchange 
>>> of information involves two parties, one at least of which has 
>>> created some XML.
>>> Thanks for the JXPath link. What worries me about it though is that 
>>> it won't necessarily use the same DOM implementation as JSTL 
>>> implementation, meaning that they won't work with each other. It 
>>> seems a shame if this is the case. I'll look at it though - it might 
>>> not be that bad.
>>> Cheers
>>> Murray
>>>
>>> At 01:33 AM 7/05/2004, you wrote:
>>>
>>>> This is outside the scope of the taglibrary, JSTL xml taglibrary is 
>>>> for presentation of xml content, not for its manipulation. I 
>>>> recommend looking into a package such as JXPath to accomplish 
>>>> manipulation of the content of a DOM object. the nice thing is that 
>>>> JXPath can be scripted into a JSP, Servlet or Struts Action, which 
>>>> gives you the fredom to move it out of the Presentation layer (where 
>>>> you probibly shouldn't be placing such logic).
>>>>
>>>> http://jakarta.apache.org/commons/jxpath/
>>>>
>>>> Good Luck
>>>> -Mark
>>>>
>>>> Murray Lang wrote:
>>>>
>>>>> Hi
>>>>> I've been using the XML tags in JSTL and found them very useful, 
>>>>> however now I need to add an attribute to an XML element and have 
>>>>> hit a brick wall.
>>>>>
>>>>> I've tried using <c:set> and EL, treating a DOM object as a bean, 
>>>>> but the DOM interface is implementation-dependent and my 
>>>>> implementation (xerces) doesn't lend itself to adding attributes 
>>>>> with the simple EL view of bean properties.
>>>>>
>>>>> It seems to me that <x:set> needs to have a "target"attribute along 
>>>>> the same lines as <c:set>, but accepting an XPath expression.
>>>>> eg
>>>>>     <x:set select="12345" 
>>>>> target="$myRoot//myElement[position()=0]/@myAttribute" />
>>>>> where:
>>>>>     - select can be either an XPath expression or an immediate value.
>>>>>     - if @myAttribute doesn't currently exist in the element then 
>>>>> it is created.
>>>>>
>>>>> Does this make sense?
>>>>> Is there a simple, portable, way of achieving this using JSTL as it 
>>>>> stands? (Using <c:set> is not portable due to DOM being 
>>>>> implementation dependent).
>>>>>
>>>>> Thanks
>>>>> Murray
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>>> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>
>>
>> -- 
>> Stefan Frank
>> iBioS - Intelligent BioInformatics Systems
>> http://www.dkfz-heidelberg.de/ibios
>> DKFZ - German Cancer Research Center
>> Im Neuenheimer Feld 580
>> 69120 Heidelberg
>> Tel.: +49 (0) 6221 42-3612
>> Mail: s.frank@dkfz-heidelberg.de
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by Pierre Delisle <Pi...@Sun.COM>.
Murray,

> OK, so I can settle (grudgingly) for writing/finding another XML tag
> library that can actually manipulate XML. The shame of it is that if
> I want to also use the JSTL tags (which I like very much) then I'll
> have to duplicate all of my XPath expressions and context variables
> for the new tags because the only JSTL tag that exposes a standard
> w3c.dom.Document is <x:parse>. If only <x:set> and <x:forEach> had a
> "varDom" attribute, then the JSTL could be easily complemented by
> other (naughty) XML-based tag libraries.

When an XPath expression is evaluated, the result is mapped to
a Java type according to the following rules:

XPath       Java
-----       ----
boolean  -> java.lang.Boolean
number   -> java.lang.Number
string   -> java.lang.String
node-set -> Type usable by JSTL XML-manipulation
            tags in the same JSTL implementation. The
            specific Java type representing node-sets
            may thus vary by implementation.

If I understand you correctly, given that the  only mapping that's not
specified is 'node-set',  you'd want the  capability  to  force  the
mapping  of an  XPath node-set to  be  of a  specific  type, e.g.
org.w3c.dom.NodeList. Correct?

    -- Pierre

Murray Lang wrote:

> Are you saying that if I want to get user input (from a <form>) into XML 
> for a back-end system then JSP is not suitable?. I can't accept that.
> 
> I could use Struts (which seems like overkill), or write a tag library 
> that took all of the <form> values and spat out w3c.dom.Document, but 
> any changes to the input options would then require that a bean and its 
> JAR be recompiled and  re-deployed. Using a generic XML Tag library to 
> put the values into an XML tree would be more maintainable.
> 
> OK, so I can settle (grudgingly) for writing/finding another XML tag 
> library that can actually manipulate XML. The shame of it is that if I 
> want to also use the JSTL tags (which I like very much) then I'll have 
> to duplicate all of my XPath expressions and context variables for the 
> new tags because the only JSTL tag that exposes a standard 
> w3c.dom.Document is <x:parse>. If only <x:set> and <x:forEach> had a 
> "varDom" attribute, then the JSTL could be easily complemented by other 
> (naughty) XML-based tag libraries.
> 
> Murray
> 
> 
> At 04:24 PM 7/05/2004, you wrote:
> 
>> hey, come on, this is just a jsp - you would not really want to litter 
>> your presentation layer with all sorts of business-logic: if jstl goes 
>> down this path, it will end up being a crippled version of cfml or 
>> even worse asp...
>>
>> Murray Lang wrote:
>>
>>> Actually, what the Sun JSTL web page says is:
>>> "JSTL has support for common, structural tasks such as iteration and 
>>> conditionals, tags for manipulating XML documents, 
>>> internationalization tags, and SQL tags."
>>> "manipulating"!
>>> Anyway, I take your point that it is outside the scope of the JSTL 
>>> XML tags at the moment. It seems to me a rather arbitrary limitation 
>>> though. As the JSTL documentation says: "...when companies cooperate 
>>> over the web, XML is the data format of choice for exchanging 
>>> information.". IMHO being unable to manipulate XML is odd for a 
>>> technology that has such language in it's documentation. An exchange 
>>> of information involves two parties, one at least of which has 
>>> created some XML.
>>> Thanks for the JXPath link. What worries me about it though is that 
>>> it won't necessarily use the same DOM implementation as JSTL 
>>> implementation, meaning that they won't work with each other. It 
>>> seems a shame if this is the case. I'll look at it though - it might 
>>> not be that bad.
>>> Cheers
>>> Murray
>>>
>>> At 01:33 AM 7/05/2004, you wrote:
>>>
>>>> This is outside the scope of the taglibrary, JSTL xml taglibrary is 
>>>> for presentation of xml content, not for its manipulation. I 
>>>> recommend looking into a package such as JXPath to accomplish 
>>>> manipulation of the content of a DOM object. the nice thing is that 
>>>> JXPath can be scripted into a JSP, Servlet or Struts Action, which 
>>>> gives you the fredom to move it out of the Presentation layer (where 
>>>> you probibly shouldn't be placing such logic).
>>>>
>>>> http://jakarta.apache.org/commons/jxpath/
>>>>
>>>> Good Luck
>>>> -Mark
>>>>
>>>> Murray Lang wrote:
>>>>
>>>>> Hi
>>>>> I've been using the XML tags in JSTL and found them very useful, 
>>>>> however now I need to add an attribute to an XML element and have 
>>>>> hit a brick wall.
>>>>>
>>>>> I've tried using <c:set> and EL, treating a DOM object as a bean, 
>>>>> but the DOM interface is implementation-dependent and my 
>>>>> implementation (xerces) doesn't lend itself to adding attributes 
>>>>> with the simple EL view of bean properties.
>>>>>
>>>>> It seems to me that <x:set> needs to have a "target"attribute along 
>>>>> the same lines as <c:set>, but accepting an XPath expression.
>>>>> eg
>>>>>     <x:set select="12345" 
>>>>> target="$myRoot//myElement[position()=0]/@myAttribute" />
>>>>> where:
>>>>>     - select can be either an XPath expression or an immediate value.
>>>>>     - if @myAttribute doesn't currently exist in the element then 
>>>>> it is created.
>>>>>
>>>>> Does this make sense?
>>>>> Is there a simple, portable, way of achieving this using JSTL as it 
>>>>> stands? (Using <c:set> is not portable due to DOM being 
>>>>> implementation dependent).
>>>>>
>>>>> Thanks
>>>>> Murray
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>>> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>
>>
>> -- 
>> Stefan Frank
>> iBioS - Intelligent BioInformatics Systems
>> http://www.dkfz-heidelberg.de/ibios
>> DKFZ - German Cancer Research Center
>> Im Neuenheimer Feld 580
>> 69120 Heidelberg
>> Tel.: +49 (0) 6221 42-3612
>> Mail: s.frank@dkfz-heidelberg.de
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by Murray Lang <mu...@metoceanengineers.com>.
Are you saying that if I want to get user input (from a <form>) into XML 
for a back-end system then JSP is not suitable?. I can't accept that.

I could use Struts (which seems like overkill), or write a tag library that 
took all of the <form> values and spat out w3c.dom.Document, but any 
changes to the input options would then require that a bean and its JAR be 
recompiled and  re-deployed. Using a generic XML Tag library to put the 
values into an XML tree would be more maintainable.

OK, so I can settle (grudgingly) for writing/finding another XML tag 
library that can actually manipulate XML. The shame of it is that if I want 
to also use the JSTL tags (which I like very much) then I'll have to 
duplicate all of my XPath expressions and context variables for the new 
tags because the only JSTL tag that exposes a standard w3c.dom.Document is 
<x:parse>. If only <x:set> and <x:forEach> had a "varDom" attribute, then 
the JSTL could be easily complemented by other (naughty) XML-based tag 
libraries.

Murray


At 04:24 PM 7/05/2004, you wrote:
>hey, come on, this is just a jsp - you would not really want to litter 
>your presentation layer with all sorts of business-logic: if jstl goes 
>down this path, it will end up being a crippled version of cfml or even 
>worse asp...
>
>Murray Lang wrote:
>>Actually, what the Sun JSTL web page says is:
>>"JSTL has support for common, structural tasks such as iteration and 
>>conditionals, tags for manipulating XML documents, internationalization 
>>tags, and SQL tags."
>>"manipulating"!
>>Anyway, I take your point that it is outside the scope of the JSTL XML 
>>tags at the moment. It seems to me a rather arbitrary limitation though. 
>>As the JSTL documentation says: "...when companies cooperate over the 
>>web, XML is the data format of choice for exchanging information.". IMHO 
>>being unable to manipulate XML is odd for a technology that has such 
>>language in it's documentation. An exchange of information involves two 
>>parties, one at least of which has created some XML.
>>Thanks for the JXPath link. What worries me about it though is that it 
>>won't necessarily use the same DOM implementation as JSTL implementation, 
>>meaning that they won't work with each other. It seems a shame if this is 
>>the case. I'll look at it though - it might not be that bad.
>>Cheers
>>Murray
>>
>>At 01:33 AM 7/05/2004, you wrote:
>>
>>>This is outside the scope of the taglibrary, JSTL xml taglibrary is for 
>>>presentation of xml content, not for its manipulation. I recommend 
>>>looking into a package such as JXPath to accomplish manipulation of the 
>>>content of a DOM object. the nice thing is that JXPath can be scripted 
>>>into a JSP, Servlet or Struts Action, which gives you the fredom to move 
>>>it out of the Presentation layer (where you probibly shouldn't be 
>>>placing such logic).
>>>
>>>http://jakarta.apache.org/commons/jxpath/
>>>
>>>Good Luck
>>>-Mark
>>>
>>>Murray Lang wrote:
>>>
>>>>Hi
>>>>I've been using the XML tags in JSTL and found them very useful, 
>>>>however now I need to add an attribute to an XML element and have hit a 
>>>>brick wall.
>>>>
>>>>I've tried using <c:set> and EL, treating a DOM object as a bean, but 
>>>>the DOM interface is implementation-dependent and my implementation 
>>>>(xerces) doesn't lend itself to adding attributes with the simple EL 
>>>>view of bean properties.
>>>>
>>>>It seems to me that <x:set> needs to have a "target"attribute along the 
>>>>same lines as <c:set>, but accepting an XPath expression.
>>>>eg
>>>>     <x:set select="12345" 
>>>> target="$myRoot//myElement[position()=0]/@myAttribute" />
>>>>where:
>>>>     - select can be either an XPath expression or an immediate value.
>>>>     - if @myAttribute doesn't currently exist in the element then it 
>>>> is created.
>>>>
>>>>Does this make sense?
>>>>Is there a simple, portable, way of achieving this using JSTL as it 
>>>>stands? (Using <c:set> is not portable due to DOM being implementation 
>>>>dependent).
>>>>
>>>>Thanks
>>>>Murray
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>
>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>--
>Stefan Frank
>iBioS - Intelligent BioInformatics Systems
>http://www.dkfz-heidelberg.de/ibios
>DKFZ - German Cancer Research Center
>Im Neuenheimer Feld 580
>69120 Heidelberg
>Tel.: +49 (0) 6221 42-3612
>Mail: s.frank@dkfz-heidelberg.de
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by Murray Lang <mu...@metoceanengineers.com>.
Writing an XML tag library that works with JSTL is complicated by the fact 
that the DOM used in JSTL is implementation-dependent.
<x:parse> has the "varDom" attribute which makes the result available in a 
known format, but that's it. So if I want to write a tag library that 
modifies XML then I probably also have to implement the read stuff as well 
and throw away the JSTL tags. Seems silly to me.

Murray

At 08:58 PM 7/05/2004, you wrote:
>Murray,
>
> > "JSTL has support for common, structural tasks such as iteration and
> > conditionals, tags for manipulating XML documents, internationalization
> > tags, and SQL tags."
> >
> > "manipulating"!
>
>Clearly that was a general statement not to be taken in a "Legal sense"... 
>it is poorly stated
>
>If you want things "in" JSTL, I would recommend you join the JCP that 
>established it, this is simply an Apache project to establish a working 
>reference implementation of the specification. We cannot make 
>modifications to the taglibrary that will make it incompatible with the 
>JSTL specification.
>
>One could, however, extend the standard taglibrary themselves if they 
>wished to have such functionality. There's no reason you can't write your 
>own tag that will modify the XML dom. In fact, my earlier suggestion to 
>use JXPath gives you most of the underlying implementation for manipulation...
>
>Cheers,
>Mark
>
>Murray Lang wrote:
>
>>Actually, what the Sun JSTL web page says is:
>>
>>Anyway, I take your point that it is outside the scope of the JSTL XML 
>>tags at the moment. It seems to me a rather arbitrary limitation though. 
>>As the JSTL documentation says: "...when companies cooperate over the 
>>web, XML is the data format of choice for exchanging information.". IMHO 
>>being unable to manipulate XML is odd for a technology that has such 
>>language in it's documentation. An exchange of information involves two 
>>parties, one at least of which has created some XML.
>>Thanks for the JXPath link. What worries me about it though is that it 
>>won't necessarily use the same DOM implementation as JSTL implementation, 
>>meaning that they won't work with each other. It seems a shame if this is 
>>the case. I'll look at it though - it might not be that bad.
>>Cheers
>>Murray
>>
>>At 01:33 AM 7/05/2004, you wrote:
>>
>>>This is outside the scope of the taglibrary, JSTL xml taglibrary is for 
>>>presentation of xml content, not for its manipulation. I recommend 
>>>looking into a package such as JXPath to accomplish manipulation of the 
>>>content of a DOM object. the nice thing is that JXPath can be scripted 
>>>into a JSP, Servlet or Struts Action, which gives you the fredom to move 
>>>it out of the Presentation layer (where you probibly shouldn't be 
>>>placing such logic).
>>>
>>>http://jakarta.apache.org/commons/jxpath/
>>>
>>>Good Luck
>>>-Mark
>>>
>>>Murray Lang wrote:
>>>
>>>>Hi
>>>>I've been using the XML tags in JSTL and found them very useful, 
>>>>however now I need to add an attribute to an XML element and have hit a 
>>>>brick wall.
>>>>
>>>>I've tried using <c:set> and EL, treating a DOM object as a bean, but 
>>>>the DOM interface is implementation-dependent and my implementation 
>>>>(xerces) doesn't lend itself to adding attributes with the simple EL 
>>>>view of bean properties.
>>>>
>>>>It seems to me that <x:set> needs to have a "target"attribute along the 
>>>>same lines as <c:set>, but accepting an XPath expression.
>>>>eg
>>>>     <x:set select="12345" 
>>>> target="$myRoot//myElement[position()=0]/@myAttribute" />
>>>>where:
>>>>     - select can be either an XPath expression or an immediate value.
>>>>     - if @myAttribute doesn't currently exist in the element then it 
>>>> is created.
>>>>
>>>>Does this make sense?
>>>>Is there a simple, portable, way of achieving this using JSTL as it 
>>>>stands? (Using <c:set> is not portable due to DOM being implementation 
>>>>dependent).
>>>>
>>>>Thanks
>>>>Murray
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>
>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>--
>Mark Diggory
>Software Developer
>Harvard MIT Data Center
>http://www.hmdc.harvard.edu
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by Murray Lang <mu...@metoceanengineers.com>.
For example, putting user input from a form into XML. Is that a stupid 
thing to do?

At 08:08 PM 7/05/2004, you wrote:
>It's perfectly valid to perform those tasks for the sake of presentation 
>logic.
>Just because I'm manipulating an XML document doesn't mean that I'm performing
>business logic. Does transforming your XML data to (X)HTML qualify as business
>logic? As another example, an article by Bob DuCharme for XML.com
>(http://www.xml.com/pub/a/2004/04/07/tr.html) outlines how to use XSLT to add
>an id attribute to all elements, or to just a specific list of elements. This
>may have nothing to do with business logic but it's quite useful for creating
>links within an XHTML document. In fact, that article hits very close to a
>solution for the original question...
>
>Quoting Stefan Frank <s....@dkfz-heidelberg.de>:
>
> > hey, come on, this is just a jsp - you would not really want to litter
> > your presentation layer with all sorts of business-logic: if jstl goes
> > down this path, it will end up being a crippled version of cfml or even
> > worse asp...
> >
> > Murray Lang wrote:
> > > Actually, what the Sun JSTL web page says is:
> > >
> > > "JSTL has support for common, structural tasks such as iteration and
> > > conditionals, tags for manipulating XML documents, internationalization
> > > tags, and SQL tags."
> > >
> > > "manipulating"!
> > >
> > > Anyway, I take your point that it is outside the scope of the JSTL XML
> > > tags at the moment. It seems to me a rather arbitrary limitation though.
> > > As the JSTL documentation says: "...when companies cooperate over the
> > > web, XML is the data format of choice for exchanging information.". IMHO
> > > being unable to manipulate XML is odd for a technology that has such
> > > language in it's documentation. An exchange of information involves two
> > > parties, one at least of which has created some XML.
> > >
> > > Thanks for the JXPath link. What worries me about it though is that it
> > > won't necessarily use the same DOM implementation as JSTL
> > > implementation, meaning that they won't work with each other. It seems a
> > > shame if this is the case. I'll look at it though - it might not be that
> > > bad.
> > >
> > > Cheers
> > > Murray
> > >
> > >
> > >
> > > At 01:33 AM 7/05/2004, you wrote:
> > >
> > >> This is outside the scope of the taglibrary, JSTL xml taglibrary is
> > >> for presentation of xml content, not for its manipulation. I recommend
> > >> looking into a package such as JXPath to accomplish manipulation of
> > >> the content of a DOM object. the nice thing is that JXPath can be
> > >> scripted into a JSP, Servlet or Struts Action, which gives you the
> > >> fredom to move it out of the Presentation layer (where you probibly
> > >> shouldn't be placing such logic).
> > >>
> > >> http://jakarta.apache.org/commons/jxpath/
> > >>
> > >> Good Luck
> > >> -Mark
> > >>
> > >> Murray Lang wrote:
> > >>
> > >>> Hi
> > >>> I've been using the XML tags in JSTL and found them very useful,
> > >>> however now I need to add an attribute to an XML element and have hit
> > >>> a brick wall.
> > >>>
> > >>> I've tried using <c:set> and EL, treating a DOM object as a bean, but
> > >>> the DOM interface is implementation-dependent and my implementation
> > >>> (xerces) doesn't lend itself to adding attributes with the simple EL
> > >>> view of bean properties.
> > >>>
> > >>> It seems to me that <x:set> needs to have a "target"attribute along
> > >>> the same lines as <c:set>, but accepting an XPath expression.
> > >>> eg
> > >>>     <x:set select="12345"
> > >>> target="$myRoot//myElement[position()=0]/@myAttribute" />
> > >>> where:
> > >>>     - select can be either an XPath expression or an immediate value.
> > >>>     - if @myAttribute doesn't currently exist in the element then it
> > >>> is created.
> > >>>
> > >>> Does this make sense?
> > >>> Is there a simple, portable, way of achieving this using JSTL as it
> > >>> stands? (Using <c:set> is not portable due to DOM being
> > >>> implementation dependent).
> > >>>
> > >>> Thanks
> > >>> Murray
> >
> > --
> > Stefan Frank
> > iBioS - Intelligent BioInformatics Systems
> > http://www.dkfz-heidelberg.de/ibios
> > DKFZ - German Cancer Research Center
> > Im Neuenheimer Feld 580
> > 69120 Heidelberg
> > Tel.: +49 (0) 6221 42-3612
> > Mail: s.frank@dkfz-heidelberg.de
>
>--
>Kris Schneider <ma...@dotech.com>
>D.O.Tech       <http://www.dotech.com/>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by "Mark R. Diggory" <md...@latte.harvard.edu>.
Kris Schneider wrote:

> ;-) I'm not sure how I got stuck holding the bag for "physically 
> altering the original DOM object", JXPath was your suggestion, wasn't 
> it? 

That wasn't my intention, I was just showing and optional strategy. I'm 
always one to play Devils Advocate... ;-) Lord knows I sometimes do 
things in JSP pages that would make Shawn Bayern come running back from 
Law School ;-)

> My original response, which I still stand by, was, "It sounds like 
> you'd be better off using XSLT and the <x:transform> tag..." The two 
> examples I gave below both use transformation and don't touch the 
> original data. 
> But you're absolutely right in that you need to take care 
> with what you do in the name of presentation logic to ensure that side 
> effects don't end up wreaking havoc on your model. Of course, that's 
> generically applicable to other templating/scripting/view-rendering 
> technologies besides JSP & JSTL.
> 

this all makes sense, but with large amounts of data, transforms that 
are basically duplications of the content can get expensive. My own 
projects tend to push this envelope, so I get around the memory 
constraints by sometimes directly manipulating the DOM content using 
JXPath, but its usually in a control/model portion of the application 
(struts actions or servlets) not really ever in JSP's directly.

Lately I'm starting to work more with XMLDB and XUpdates, I'd like to 
eventually see a generic XUpdate engine that could easily be applied to 
DOM objects.

Cheers,
-Mark


> Mark R. Diggory wrote:
> 
>> Hey, if its all in the name of presentation, then who am I to argue.
>>
>> But there is a conceptual dfiference your overlooking here. There is a 
>> big difference between taking a DOM and doing an xslt transform to 
>> produce new output vs. physically altering the original DOM object, 
>> The former is a "readonly" process, and the later is a "write" 
>> process. What if that DOM was actually implemented over some 
>> persistent source, now your using your presentation layer to do 
>> buisness logic...
>>
>> Granted, JSTL already "bleeds" over the boundaries of "read/write" 
>> with the sql tags, and its rather difficult to define a boundary for 
>> objects acted on by the "c:set" tag as well.
>>
>> -Mark
>>
>> Kris Schneider wrote:
>>
>>> It's perfectly valid to perform those tasks for the sake of 
>>> presentation logic.
>>> Just because I'm manipulating an XML document doesn't mean that I'm 
>>> performing
>>> business logic. Does transforming your XML data to (X)HTML qualify as 
>>> business
>>> logic? As another example, an article by Bob DuCharme for XML.com
>>> (http://www.xml.com/pub/a/2004/04/07/tr.html) outlines how to use 
>>> XSLT to add
>>> an id attribute to all elements, or to just a specific list of 
>>> elements. This
>>> may have nothing to do with business logic but it's quite useful for 
>>> creating
>>> links within an XHTML document. In fact, that article hits very close 
>>> to a
>>> solution for the original question...
>>>
>>> Quoting Stefan Frank <s....@dkfz-heidelberg.de>:
>>>
>>>  
>>>
>>>> hey, come on, this is just a jsp - you would not really want to 
>>>> litter your presentation layer with all sorts of business-logic: if 
>>>> jstl goes down this path, it will end up being a crippled version of 
>>>> cfml or even worse asp...
>>>>
>>>> Murray Lang wrote:
>>>>  
>>>>
>>>>> Actually, what the Sun JSTL web page says is:
>>>>>
>>>>> "JSTL has support for common, structural tasks such as iteration 
>>>>> and conditionals, tags for manipulating XML documents, 
>>>>> internationalization tags, and SQL tags."
>>>>>
>>>>> "manipulating"!
>>>>>
>>>>> Anyway, I take your point that it is outside the scope of the JSTL 
>>>>> XML tags at the moment. It seems to me a rather arbitrary 
>>>>> limitation though. As the JSTL documentation says: "...when 
>>>>> companies cooperate over the web, XML is the data format of choice 
>>>>> for exchanging information.". IMHO being unable to manipulate XML 
>>>>> is odd for a technology that has such language in it's 
>>>>> documentation. An exchange of information involves two parties, one 
>>>>> at least of which has created some XML.
>>>>>
>>>>> Thanks for the JXPath link. What worries me about it though is that 
>>>>> it won't necessarily use the same DOM implementation as JSTL 
>>>>> implementation, meaning that they won't work with each other. It 
>>>>> seems a shame if this is the case. I'll look at it though - it 
>>>>> might not be that bad.
>>>>>
>>>>> Cheers
>>>>> Murray
>>>>>
>>>>>
>>>>>
>>>>> At 01:33 AM 7/05/2004, you wrote:
>>>>>
>>>>>    
>>>>>
>>>>>> This is outside the scope of the taglibrary, JSTL xml taglibrary 
>>>>>> is for presentation of xml content, not for its manipulation. I 
>>>>>> recommend looking into a package such as JXPath to accomplish 
>>>>>> manipulation of the content of a DOM object. the nice thing is 
>>>>>> that JXPath can be scripted into a JSP, Servlet or Struts Action, 
>>>>>> which gives you the fredom to move it out of the Presentation 
>>>>>> layer (where you probibly shouldn't be placing such logic).
>>>>>>
>>>>>> http://jakarta.apache.org/commons/jxpath/
>>>>>>
>>>>>> Good Luck
>>>>>> -Mark
>>>>>>
>>>>>> Murray Lang wrote:
>>>>>>
>>>>>>      
>>>>>>
>>>>>>> Hi
>>>>>>> I've been using the XML tags in JSTL and found them very useful, 
>>>>>>> however now I need to add an attribute to an XML element and have 
>>>>>>> hit a brick wall.
>>>>>>>
>>>>>>> I've tried using <c:set> and EL, treating a DOM object as a bean, 
>>>>>>> but the DOM interface is implementation-dependent and my 
>>>>>>> implementation (xerces) doesn't lend itself to adding attributes 
>>>>>>> with the simple EL view of bean properties.
>>>>>>>
>>>>>>> It seems to me that <x:set> needs to have a "target"attribute 
>>>>>>> along the same lines as <c:set>, but accepting an XPath expression.
>>>>>>> eg
>>>>>>>    <x:set select="12345" 
>>>>>>> target="$myRoot//myElement[position()=0]/@myAttribute" />
>>>>>>> where:
>>>>>>>    - select can be either an XPath expression or an immediate value.
>>>>>>>    - if @myAttribute doesn't currently exist in the element then 
>>>>>>> it is created.
>>>>>>>
>>>>>>> Does this make sense?
>>>>>>> Is there a simple, portable, way of achieving this using JSTL as 
>>>>>>> it stands? (Using <c:set> is not portable due to DOM being 
>>>>>>> implementation dependent).
>>>>>>>
>>>>>>> Thanks
>>>>>>> Murray
>>>>>>>         
>>>>
>>>>
>>>> -- 
>>>> Stefan Frank
>>>> iBioS - Intelligent BioInformatics Systems
>>>> http://www.dkfz-heidelberg.de/ibios
>>>> DKFZ - German Cancer Research Center
>>>> Im Neuenheimer Feld 580
>>>> 69120 Heidelberg
>>>> Tel.: +49 (0) 6221 42-3612
>>>> Mail: s.frank@dkfz-heidelberg.de
> 
> 

-- 
Mark Diggory
Software Developer
Harvard MIT Data Center
http://www.hmdc.harvard.edu

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by Kris Schneider <kr...@dotech.com>.
;-) I'm not sure how I got stuck holding the bag for "physically 
altering the original DOM object", JXPath was your suggestion, wasn't 
it? My original response, which I still stand by, was, "It sounds like 
you'd be better off using XSLT and the <x:transform> tag..." The two 
examples I gave below both use transformation and don't touch the 
original data. But you're absolutely right in that you need to take care 
with what you do in the name of presentation logic to ensure that side 
effects don't end up wreaking havoc on your model. Of course, that's 
generically applicable to other templating/scripting/view-rendering 
technologies besides JSP & JSTL.

Mark R. Diggory wrote:
> Hey, if its all in the name of presentation, then who am I to argue.
> 
> But there is a conceptual dfiference your overlooking here. There is a 
> big difference between taking a DOM and doing an xslt transform to 
> produce new output vs. physically altering the original DOM object, The 
> former is a "readonly" process, and the later is a "write" process. What 
> if that DOM was actually implemented over some persistent source, now 
> your using your presentation layer to do buisness logic...
> 
> Granted, JSTL already "bleeds" over the boundaries of "read/write" with 
> the sql tags, and its rather difficult to define a boundary for objects 
> acted on by the "c:set" tag as well.
> 
> -Mark
> 
> Kris Schneider wrote:
> 
>> It's perfectly valid to perform those tasks for the sake of 
>> presentation logic.
>> Just because I'm manipulating an XML document doesn't mean that I'm 
>> performing
>> business logic. Does transforming your XML data to (X)HTML qualify as 
>> business
>> logic? As another example, an article by Bob DuCharme for XML.com
>> (http://www.xml.com/pub/a/2004/04/07/tr.html) outlines how to use XSLT 
>> to add
>> an id attribute to all elements, or to just a specific list of 
>> elements. This
>> may have nothing to do with business logic but it's quite useful for 
>> creating
>> links within an XHTML document. In fact, that article hits very close 
>> to a
>> solution for the original question...
>>
>> Quoting Stefan Frank <s....@dkfz-heidelberg.de>:
>>
>>  
>>
>>> hey, come on, this is just a jsp - you would not really want to 
>>> litter your presentation layer with all sorts of business-logic: if 
>>> jstl goes down this path, it will end up being a crippled version of 
>>> cfml or even worse asp...
>>>
>>> Murray Lang wrote:
>>>   
>>>
>>>> Actually, what the Sun JSTL web page says is:
>>>>
>>>> "JSTL has support for common, structural tasks such as iteration and 
>>>> conditionals, tags for manipulating XML documents, 
>>>> internationalization tags, and SQL tags."
>>>>
>>>> "manipulating"!
>>>>
>>>> Anyway, I take your point that it is outside the scope of the JSTL 
>>>> XML tags at the moment. It seems to me a rather arbitrary limitation 
>>>> though. As the JSTL documentation says: "...when companies cooperate 
>>>> over the web, XML is the data format of choice for exchanging 
>>>> information.". IMHO being unable to manipulate XML is odd for a 
>>>> technology that has such language in it's documentation. An exchange 
>>>> of information involves two parties, one at least of which has 
>>>> created some XML.
>>>>
>>>> Thanks for the JXPath link. What worries me about it though is that 
>>>> it won't necessarily use the same DOM implementation as JSTL 
>>>> implementation, meaning that they won't work with each other. It 
>>>> seems a shame if this is the case. I'll look at it though - it might 
>>>> not be that bad.
>>>>
>>>> Cheers
>>>> Murray
>>>>
>>>>
>>>>
>>>> At 01:33 AM 7/05/2004, you wrote:
>>>>
>>>>     
>>>>
>>>>> This is outside the scope of the taglibrary, JSTL xml taglibrary is 
>>>>> for presentation of xml content, not for its manipulation. I 
>>>>> recommend looking into a package such as JXPath to accomplish 
>>>>> manipulation of the content of a DOM object. the nice thing is that 
>>>>> JXPath can be scripted into a JSP, Servlet or Struts Action, which 
>>>>> gives you the fredom to move it out of the Presentation layer 
>>>>> (where you probibly shouldn't be placing such logic).
>>>>>
>>>>> http://jakarta.apache.org/commons/jxpath/
>>>>>
>>>>> Good Luck
>>>>> -Mark
>>>>>
>>>>> Murray Lang wrote:
>>>>>
>>>>>       
>>>>>
>>>>>> Hi
>>>>>> I've been using the XML tags in JSTL and found them very useful, 
>>>>>> however now I need to add an attribute to an XML element and have 
>>>>>> hit a brick wall.
>>>>>>
>>>>>> I've tried using <c:set> and EL, treating a DOM object as a bean, 
>>>>>> but the DOM interface is implementation-dependent and my 
>>>>>> implementation (xerces) doesn't lend itself to adding attributes 
>>>>>> with the simple EL view of bean properties.
>>>>>>
>>>>>> It seems to me that <x:set> needs to have a "target"attribute 
>>>>>> along the same lines as <c:set>, but accepting an XPath expression.
>>>>>> eg
>>>>>>    <x:set select="12345" 
>>>>>> target="$myRoot//myElement[position()=0]/@myAttribute" />
>>>>>> where:
>>>>>>    - select can be either an XPath expression or an immediate value.
>>>>>>    - if @myAttribute doesn't currently exist in the element then 
>>>>>> it is created.
>>>>>>
>>>>>> Does this make sense?
>>>>>> Is there a simple, portable, way of achieving this using JSTL as 
>>>>>> it stands? (Using <c:set> is not portable due to DOM being 
>>>>>> implementation dependent).
>>>>>>
>>>>>> Thanks
>>>>>> Murray
>>>>>>         
>>>
>>> -- 
>>> Stefan Frank
>>> iBioS - Intelligent BioInformatics Systems
>>> http://www.dkfz-heidelberg.de/ibios
>>> DKFZ - German Cancer Research Center
>>> Im Neuenheimer Feld 580
>>> 69120 Heidelberg
>>> Tel.: +49 (0) 6221 42-3612
>>> Mail: s.frank@dkfz-heidelberg.de

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by "Mark R. Diggory" <md...@latte.harvard.edu>.
Hey, if its all in the name of presentation, then who am I to argue.

But there is a conceptual dfiference your overlooking here. There is a 
big difference between taking a DOM and doing an xslt transform to 
produce new output vs. physically altering the original DOM object, The 
former is a "readonly" process, and the later is a "write" process. What 
if that DOM was actually implemented over some persistent source, now 
your using your presentation layer to do buisness logic...

Granted, JSTL already "bleeds" over the boundaries of "read/write" with 
the sql tags, and its rather difficult to define a boundary for objects 
acted on by the "c:set" tag as well.

-Mark

Kris Schneider wrote:

>It's perfectly valid to perform those tasks for the sake of presentation logic.
>Just because I'm manipulating an XML document doesn't mean that I'm performing
>business logic. Does transforming your XML data to (X)HTML qualify as business
>logic? As another example, an article by Bob DuCharme for XML.com
>(http://www.xml.com/pub/a/2004/04/07/tr.html) outlines how to use XSLT to add
>an id attribute to all elements, or to just a specific list of elements. This
>may have nothing to do with business logic but it's quite useful for creating
>links within an XHTML document. In fact, that article hits very close to a
>solution for the original question...
>
>Quoting Stefan Frank <s....@dkfz-heidelberg.de>:
>
>  
>
>>hey, come on, this is just a jsp - you would not really want to litter 
>>your presentation layer with all sorts of business-logic: if jstl goes 
>>down this path, it will end up being a crippled version of cfml or even 
>>worse asp...
>>
>>Murray Lang wrote:
>>    
>>
>>>Actually, what the Sun JSTL web page says is:
>>>
>>>"JSTL has support for common, structural tasks such as iteration and 
>>>conditionals, tags for manipulating XML documents, internationalization 
>>>tags, and SQL tags."
>>>
>>>"manipulating"!
>>>
>>>Anyway, I take your point that it is outside the scope of the JSTL XML 
>>>tags at the moment. It seems to me a rather arbitrary limitation though. 
>>>As the JSTL documentation says: "...when companies cooperate over the 
>>>web, XML is the data format of choice for exchanging information.". IMHO 
>>>being unable to manipulate XML is odd for a technology that has such 
>>>language in it's documentation. An exchange of information involves two 
>>>parties, one at least of which has created some XML.
>>>
>>>Thanks for the JXPath link. What worries me about it though is that it 
>>>won't necessarily use the same DOM implementation as JSTL 
>>>implementation, meaning that they won't work with each other. It seems a 
>>>shame if this is the case. I'll look at it though - it might not be that 
>>>bad.
>>>
>>>Cheers
>>>Murray
>>>
>>>
>>>
>>>At 01:33 AM 7/05/2004, you wrote:
>>>
>>>      
>>>
>>>>This is outside the scope of the taglibrary, JSTL xml taglibrary is 
>>>>for presentation of xml content, not for its manipulation. I recommend 
>>>>looking into a package such as JXPath to accomplish manipulation of 
>>>>the content of a DOM object. the nice thing is that JXPath can be 
>>>>scripted into a JSP, Servlet or Struts Action, which gives you the 
>>>>fredom to move it out of the Presentation layer (where you probibly 
>>>>shouldn't be placing such logic).
>>>>
>>>>http://jakarta.apache.org/commons/jxpath/
>>>>
>>>>Good Luck
>>>>-Mark
>>>>
>>>>Murray Lang wrote:
>>>>
>>>>        
>>>>
>>>>>Hi
>>>>>I've been using the XML tags in JSTL and found them very useful, 
>>>>>however now I need to add an attribute to an XML element and have hit 
>>>>>a brick wall.
>>>>>
>>>>>I've tried using <c:set> and EL, treating a DOM object as a bean, but 
>>>>>the DOM interface is implementation-dependent and my implementation 
>>>>>(xerces) doesn't lend itself to adding attributes with the simple EL 
>>>>>view of bean properties.
>>>>>
>>>>>It seems to me that <x:set> needs to have a "target"attribute along 
>>>>>the same lines as <c:set>, but accepting an XPath expression.
>>>>>eg
>>>>>    <x:set select="12345" 
>>>>>target="$myRoot//myElement[position()=0]/@myAttribute" />
>>>>>where:
>>>>>    - select can be either an XPath expression or an immediate value.
>>>>>    - if @myAttribute doesn't currently exist in the element then it 
>>>>>is created.
>>>>>
>>>>>Does this make sense?
>>>>>Is there a simple, portable, way of achieving this using JSTL as it 
>>>>>stands? (Using <c:set> is not portable due to DOM being 
>>>>>implementation dependent).
>>>>>
>>>>>Thanks
>>>>>Murray
>>>>>          
>>>>>
>>-- 
>>Stefan Frank
>>iBioS - Intelligent BioInformatics Systems
>>http://www.dkfz-heidelberg.de/ibios
>>DKFZ - German Cancer Research Center
>>Im Neuenheimer Feld 580
>>69120 Heidelberg
>>Tel.: +49 (0) 6221 42-3612
>>Mail: s.frank@dkfz-heidelberg.de
>>    
>>
>
>  
>



Re: Adding attributes to an XML element in JSTL

Posted by Kris Schneider <kr...@dotech.com>.
It's perfectly valid to perform those tasks for the sake of presentation logic.
Just because I'm manipulating an XML document doesn't mean that I'm performing
business logic. Does transforming your XML data to (X)HTML qualify as business
logic? As another example, an article by Bob DuCharme for XML.com
(http://www.xml.com/pub/a/2004/04/07/tr.html) outlines how to use XSLT to add
an id attribute to all elements, or to just a specific list of elements. This
may have nothing to do with business logic but it's quite useful for creating
links within an XHTML document. In fact, that article hits very close to a
solution for the original question...

Quoting Stefan Frank <s....@dkfz-heidelberg.de>:

> hey, come on, this is just a jsp - you would not really want to litter 
> your presentation layer with all sorts of business-logic: if jstl goes 
> down this path, it will end up being a crippled version of cfml or even 
> worse asp...
> 
> Murray Lang wrote:
> > Actually, what the Sun JSTL web page says is:
> > 
> > "JSTL has support for common, structural tasks such as iteration and 
> > conditionals, tags for manipulating XML documents, internationalization 
> > tags, and SQL tags."
> > 
> > "manipulating"!
> > 
> > Anyway, I take your point that it is outside the scope of the JSTL XML 
> > tags at the moment. It seems to me a rather arbitrary limitation though. 
> > As the JSTL documentation says: "...when companies cooperate over the 
> > web, XML is the data format of choice for exchanging information.". IMHO 
> > being unable to manipulate XML is odd for a technology that has such 
> > language in it's documentation. An exchange of information involves two 
> > parties, one at least of which has created some XML.
> > 
> > Thanks for the JXPath link. What worries me about it though is that it 
> > won't necessarily use the same DOM implementation as JSTL 
> > implementation, meaning that they won't work with each other. It seems a 
> > shame if this is the case. I'll look at it though - it might not be that 
> > bad.
> > 
> > Cheers
> > Murray
> > 
> > 
> > 
> > At 01:33 AM 7/05/2004, you wrote:
> > 
> >> This is outside the scope of the taglibrary, JSTL xml taglibrary is 
> >> for presentation of xml content, not for its manipulation. I recommend 
> >> looking into a package such as JXPath to accomplish manipulation of 
> >> the content of a DOM object. the nice thing is that JXPath can be 
> >> scripted into a JSP, Servlet or Struts Action, which gives you the 
> >> fredom to move it out of the Presentation layer (where you probibly 
> >> shouldn't be placing such logic).
> >>
> >> http://jakarta.apache.org/commons/jxpath/
> >>
> >> Good Luck
> >> -Mark
> >>
> >> Murray Lang wrote:
> >>
> >>> Hi
> >>> I've been using the XML tags in JSTL and found them very useful, 
> >>> however now I need to add an attribute to an XML element and have hit 
> >>> a brick wall.
> >>>
> >>> I've tried using <c:set> and EL, treating a DOM object as a bean, but 
> >>> the DOM interface is implementation-dependent and my implementation 
> >>> (xerces) doesn't lend itself to adding attributes with the simple EL 
> >>> view of bean properties.
> >>>
> >>> It seems to me that <x:set> needs to have a "target"attribute along 
> >>> the same lines as <c:set>, but accepting an XPath expression.
> >>> eg
> >>>     <x:set select="12345" 
> >>> target="$myRoot//myElement[position()=0]/@myAttribute" />
> >>> where:
> >>>     - select can be either an XPath expression or an immediate value.
> >>>     - if @myAttribute doesn't currently exist in the element then it 
> >>> is created.
> >>>
> >>> Does this make sense?
> >>> Is there a simple, portable, way of achieving this using JSTL as it 
> >>> stands? (Using <c:set> is not portable due to DOM being 
> >>> implementation dependent).
> >>>
> >>> Thanks
> >>> Murray
>
> -- 
> Stefan Frank
> iBioS - Intelligent BioInformatics Systems
> http://www.dkfz-heidelberg.de/ibios
> DKFZ - German Cancer Research Center
> Im Neuenheimer Feld 580
> 69120 Heidelberg
> Tel.: +49 (0) 6221 42-3612
> Mail: s.frank@dkfz-heidelberg.de

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by Stefan Frank <s....@dkfz-heidelberg.de>.
hey, come on, this is just a jsp - you would not really want to litter 
your presentation layer with all sorts of business-logic: if jstl goes 
down this path, it will end up being a crippled version of cfml or even 
worse asp...

Murray Lang wrote:
> Actually, what the Sun JSTL web page says is:
> 
> "JSTL has support for common, structural tasks such as iteration and 
> conditionals, tags for manipulating XML documents, internationalization 
> tags, and SQL tags."
> 
> "manipulating"!
> 
> Anyway, I take your point that it is outside the scope of the JSTL XML 
> tags at the moment. It seems to me a rather arbitrary limitation though. 
> As the JSTL documentation says: "...when companies cooperate over the 
> web, XML is the data format of choice for exchanging information.". IMHO 
> being unable to manipulate XML is odd for a technology that has such 
> language in it's documentation. An exchange of information involves two 
> parties, one at least of which has created some XML.
> 
> Thanks for the JXPath link. What worries me about it though is that it 
> won't necessarily use the same DOM implementation as JSTL 
> implementation, meaning that they won't work with each other. It seems a 
> shame if this is the case. I'll look at it though - it might not be that 
> bad.
> 
> Cheers
> Murray
> 
> 
> 
> At 01:33 AM 7/05/2004, you wrote:
> 
>> This is outside the scope of the taglibrary, JSTL xml taglibrary is 
>> for presentation of xml content, not for its manipulation. I recommend 
>> looking into a package such as JXPath to accomplish manipulation of 
>> the content of a DOM object. the nice thing is that JXPath can be 
>> scripted into a JSP, Servlet or Struts Action, which gives you the 
>> fredom to move it out of the Presentation layer (where you probibly 
>> shouldn't be placing such logic).
>>
>> http://jakarta.apache.org/commons/jxpath/
>>
>> Good Luck
>> -Mark
>>
>> Murray Lang wrote:
>>
>>> Hi
>>> I've been using the XML tags in JSTL and found them very useful, 
>>> however now I need to add an attribute to an XML element and have hit 
>>> a brick wall.
>>>
>>> I've tried using <c:set> and EL, treating a DOM object as a bean, but 
>>> the DOM interface is implementation-dependent and my implementation 
>>> (xerces) doesn't lend itself to adding attributes with the simple EL 
>>> view of bean properties.
>>>
>>> It seems to me that <x:set> needs to have a "target"attribute along 
>>> the same lines as <c:set>, but accepting an XPath expression.
>>> eg
>>>     <x:set select="12345" 
>>> target="$myRoot//myElement[position()=0]/@myAttribute" />
>>> where:
>>>     - select can be either an XPath expression or an immediate value.
>>>     - if @myAttribute doesn't currently exist in the element then it 
>>> is created.
>>>
>>> Does this make sense?
>>> Is there a simple, portable, way of achieving this using JSTL as it 
>>> stands? (Using <c:set> is not portable due to DOM being 
>>> implementation dependent).
>>>
>>> Thanks
>>> Murray
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 

-- 
Stefan Frank
iBioS - Intelligent BioInformatics Systems
http://www.dkfz-heidelberg.de/ibios
DKFZ - German Cancer Research Center
Im Neuenheimer Feld 580
69120 Heidelberg
Tel.: +49 (0) 6221 42-3612
Mail: s.frank@dkfz-heidelberg.de



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by "Mark R. Diggory" <md...@latte.harvard.edu>.
Murray,

 > "JSTL has support for common, structural tasks such as iteration and
 > conditionals, tags for manipulating XML documents, internationalization
 > tags, and SQL tags."
 >
 > "manipulating"!

Clearly that was a general statement not to be taken in a "Legal 
sense"... it is poorly stated

If you want things "in" JSTL, I would recommend you join the JCP that 
established it, this is simply an Apache project to establish a working 
reference implementation of the specification. We cannot make 
modifications to the taglibrary that will make it incompatible with the 
JSTL specification.

One could, however, extend the standard taglibrary themselves if they 
wished to have such functionality. There's no reason you can't write 
your own tag that will modify the XML dom. In fact, my earlier 
suggestion to use JXPath gives you most of the underlying implementation 
for manipulation...

Cheers,
Mark

Murray Lang wrote:

> Actually, what the Sun JSTL web page says is:
> 
> 
> Anyway, I take your point that it is outside the scope of the JSTL XML 
> tags at the moment. It seems to me a rather arbitrary limitation though. 
> As the JSTL documentation says: "...when companies cooperate over the 
> web, XML is the data format of choice for exchanging information.". IMHO 
> being unable to manipulate XML is odd for a technology that has such 
> language in it's documentation. An exchange of information involves two 
> parties, one at least of which has created some XML.
> 
> Thanks for the JXPath link. What worries me about it though is that it 
> won't necessarily use the same DOM implementation as JSTL 
> implementation, meaning that they won't work with each other. It seems a 
> shame if this is the case. I'll look at it though - it might not be that 
> bad.
> 
> Cheers
> Murray
> 
> 
> 
> At 01:33 AM 7/05/2004, you wrote:
> 
>> This is outside the scope of the taglibrary, JSTL xml taglibrary is 
>> for presentation of xml content, not for its manipulation. I recommend 
>> looking into a package such as JXPath to accomplish manipulation of 
>> the content of a DOM object. the nice thing is that JXPath can be 
>> scripted into a JSP, Servlet or Struts Action, which gives you the 
>> fredom to move it out of the Presentation layer (where you probibly 
>> shouldn't be placing such logic).
>>
>> http://jakarta.apache.org/commons/jxpath/
>>
>> Good Luck
>> -Mark
>>
>> Murray Lang wrote:
>>
>>> Hi
>>> I've been using the XML tags in JSTL and found them very useful, 
>>> however now I need to add an attribute to an XML element and have hit 
>>> a brick wall.
>>>
>>> I've tried using <c:set> and EL, treating a DOM object as a bean, but 
>>> the DOM interface is implementation-dependent and my implementation 
>>> (xerces) doesn't lend itself to adding attributes with the simple EL 
>>> view of bean properties.
>>>
>>> It seems to me that <x:set> needs to have a "target"attribute along 
>>> the same lines as <c:set>, but accepting an XPath expression.
>>> eg
>>>     <x:set select="12345" 
>>> target="$myRoot//myElement[position()=0]/@myAttribute" />
>>> where:
>>>     - select can be either an XPath expression or an immediate value.
>>>     - if @myAttribute doesn't currently exist in the element then it 
>>> is created.
>>>
>>> Does this make sense?
>>> Is there a simple, portable, way of achieving this using JSTL as it 
>>> stands? (Using <c:set> is not portable due to DOM being 
>>> implementation dependent).
>>>
>>> Thanks
>>> Murray
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 

-- 
Mark Diggory
Software Developer
Harvard MIT Data Center
http://www.hmdc.harvard.edu

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by Murray Lang <mu...@metoceanengineers.com>.
Actually, what the Sun JSTL web page says is:

"JSTL has support for common, structural tasks such as iteration and 
conditionals, tags for manipulating XML documents, internationalization 
tags, and SQL tags."

"manipulating"!

Anyway, I take your point that it is outside the scope of the JSTL XML tags 
at the moment. It seems to me a rather arbitrary limitation though. As the 
JSTL documentation says: "...when companies cooperate over the web, XML is 
the data format of choice for exchanging information.". IMHO being unable 
to manipulate XML is odd for a technology that has such language in it's 
documentation. An exchange of information involves two parties, one at 
least of which has created some XML.

Thanks for the JXPath link. What worries me about it though is that it 
won't necessarily use the same DOM implementation as JSTL implementation, 
meaning that they won't work with each other. It seems a shame if this is 
the case. I'll look at it though - it might not be that bad.

Cheers
Murray



At 01:33 AM 7/05/2004, you wrote:
>This is outside the scope of the taglibrary, JSTL xml taglibrary is for 
>presentation of xml content, not for its manipulation. I recommend looking 
>into a package such as JXPath to accomplish manipulation of the content of 
>a DOM object. the nice thing is that JXPath can be scripted into a JSP, 
>Servlet or Struts Action, which gives you the fredom to move it out of the 
>Presentation layer (where you probibly shouldn't be placing such logic).
>
>http://jakarta.apache.org/commons/jxpath/
>
>Good Luck
>-Mark
>
>Murray Lang wrote:
>
>>Hi
>>I've been using the XML tags in JSTL and found them very useful, however 
>>now I need to add an attribute to an XML element and have hit a brick wall.
>>
>>I've tried using <c:set> and EL, treating a DOM object as a bean, but the 
>>DOM interface is implementation-dependent and my implementation (xerces) 
>>doesn't lend itself to adding attributes with the simple EL view of bean 
>>properties.
>>
>>It seems to me that <x:set> needs to have a "target"attribute along the 
>>same lines as <c:set>, but accepting an XPath expression.
>>eg
>>     <x:set select="12345" 
>> target="$myRoot//myElement[position()=0]/@myAttribute" />
>>where:
>>     - select can be either an XPath expression or an immediate value.
>>     - if @myAttribute doesn't currently exist in the element then it is 
>> created.
>>
>>Does this make sense?
>>Is there a simple, portable, way of achieving this using JSTL as it 
>>stands? (Using <c:set> is not portable due to DOM being implementation 
>>dependent).
>>
>>Thanks
>>Murray
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by Murray Lang <mu...@metoceanengineers.com>.
I thought of that, but it seems a messy way to do something very basic.
I might resort to it though.

At 08:12 PM 6/05/2004, you wrote:
>It sounds like you'd be better off using XSLT and the <x:transform> tag...
>
>Quoting Murray Lang <mu...@metoceanengineers.com>:
>
> > Hi
> > I've been using the XML tags in JSTL and found them very useful, however
> > now I need to add an attribute to an XML element and have hit a brick wall.
> >
> > I've tried using <c:set> and EL, treating a DOM object as a bean, but the
> > DOM interface is implementation-dependent and my implementation (xerces)
> > doesn't lend itself to adding attributes with the simple EL view of bean
> > properties.
> >
> > It seems to me that <x:set> needs to have a "target"attribute along the
> > same lines as <c:set>, but accepting an XPath expression.
> > eg
> >       <x:set select="12345"
> > target="$myRoot//myElement[position()=0]/@myAttribute" />
> > where:
> >       - select can be either an XPath expression or an immediate value.
> >       - if @myAttribute doesn't currently exist in the element then it is
> > created.
> >
> > Does this make sense?
> > Is there a simple, portable, way of achieving this using JSTL as it 
> stands?
> > (Using <c:set> is not portable due to DOM being implementation dependent).
> >
> > Thanks
> > Murray
>
>--
>Kris Schneider <ma...@dotech.com>
>D.O.Tech       <http://www.dotech.com/>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by Kris Schneider <kr...@dotech.com>.
Right. This is what I tried initially and it gave the same effect:

...
<%@ page import="org.apache.commons.jxpath.ri.*" %>
<%@ page import="org.apache.commons.jxpath.ri.model.*" %>
...
<%
JXPathContext domCtx = JXPathContext.newContext(dom);
NodePointer childPtr = (NodePointer)domCtx.getPointer("root/child");
NodePointer idPtr = childPtr.createAttribute(domCtx, new QName("id"));
idPtr.setValue("1");
%>
...

Mark R. Diggory wrote:

> I believe you would get the parent element of the attribute and use a 
> pointer to that Node to add the attribute. Look Over DOMNodePointer for 
> more details.
> 
> http://jakarta.apache.org/commons/jxpath/apidocs/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.html 
> 
> 
> -Mark
> 
> Kris Schneider wrote:
> 
>> That still doesn't seem to address the question about adding an 
>> attribute. If
>> the attribute doesn't exist, you can't access it with something like
>> domCtx.getPointer("root/child/@id"), right? I took a look at the API 
>> and this
>> seemed to work (JSTL 1.1, Xalan 2.6.0, and Xerces 2.6.2 on TC 5.0.19):
>>
>> <%@ page contentType="text/plain" %>
>> <%@ page import="org.apache.commons.jxpath.*" %>
>> <%@ page import="org.w3c.dom.*" %>
>> <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
>>
>> <x:parse varDom="dom">
>>    <root>
>>        <child>Child 1</child>
>>        <child>Child 2</child>
>>        <child>Child 3</child>
>>    </root>
>> </x:parse>
>>
>> child:    <x:out select="$dom/root/child"/>
>> child id: <x:out select="$dom/root/child/@id"/>
>>
>> <jsp:useBean id="dom" type="org.w3c.dom.Document"/>
>> <%
>> JXPathContext domCtx = JXPathContext.newContext(dom);
>> Pointer ptr = domCtx.getPointer("root/child");
>> Element elem = (Element)ptr.getNode();
>> elem.setAttribute("id", "1");
>> %>
>>
>> child:    <x:out select="$dom/root/child"/>
>> child id: <x:out select="$dom/root/child/@id"/>
>>
>> Which produced:
>>
>> child:    Child 1
>> child id:
>> child:    Child 1
>> child id: 1
>>
>> It looks like there's also a way to add an attribute through the 
>> JXPath API, but
>> you have to cast the Pointer to a NodePointer and the code's a bit 
>> uglier. Of
>> course, if you're gonna drop down to Java, there are lots of other 
>> options for
>> programmatically modifying DOM through XPath...
>>
>> Quoting "Mark R. Diggory" <md...@latte.harvard.edu>:
>>
>>  
>>
>>> You can use JXPath to manipulate the content of the DOM directly (ie 
>>> without having to instantiate a whole new copied DOM object to 
>>> establish your changes (as you whould have to do with XSLT).
>>>
>>> Say you instantiate some DOM Document object, you can use JXPath as 
>>> such:
>>>
>>> Document doc = ....;
>>> JXPathContext context = JXPathContext.newContext(doc);
>>>
>>> Iterator iter = context.iteratePointers("//some[xpath]");
>>> while (iter.hasNext()) {
>>>      Pointer pointer = (Pointer) iter.next();
>>>      System.out.println("value before change: " + pointer.getValue());
>>>      pointer.setValue(value);
>>>      System.out.println("value after change: " + pointer.getValue());
>>> }
>>>
>>> .. Serialize your DOM to wherever using whatever.
>>>
>>> Yes, by scriptable, I mean you can write your java code between <%%> 
>>> or <jsp:scriptlet></jsp:scriptlet>
>>>
>>> Maybe someday there'll be a JXPath taglibrary which would make all 
>>> this all grovy in JSP.
>>>
>>> -Mark
>>>
>>> Kris Schneider wrote:
>>>
>>>   
>>>
>>>> I'm not too familiar with JXPath, and I'm sure it's useful in other
>>>>     
>>>
>>> contexts,
>>>   
>>>
>>>> but I don't see how it's applicable to Murray's problem. Can it be 
>>>> used to
>>>>     
>>>
>>> add
>>>   
>>>
>>>> an attribute to an existing element? I'm also not sure I get the point
>>>>     
>>>
>>> about
>>>   
>>>
>>>> "JXPath can be scripted into a JSP". Do you mean something besides:
>>>>
>>>> <%
>>>> Foo fooCtx = (Foo)JXPathContext.newContext(myFoo);
>>>> %>
>>>>
>>>> Quoting "Mark R. Diggory" <md...@latte.harvard.edu>:
>>>>
>>>>
>>>>
>>>>     
>>>>
>>>>> This is outside the scope of the taglibrary, JSTL xml taglibrary is 
>>>>> for presentation of xml content, not for its manipulation. I 
>>>>> recommend looking into a package such as JXPath to accomplish 
>>>>> manipulation of the content of a DOM object. the nice thing is that 
>>>>> JXPath can be scripted into a JSP, Servlet or Struts Action, which 
>>>>> gives you the fredom to move it out of the Presentation layer 
>>>>> (where you probibly shouldn't be placing such logic).
>>>>>
>>>>> http://jakarta.apache.org/commons/jxpath/
>>>>>
>>>>> Good Luck
>>>>> -Mark
>>>>>
>>>>> Murray Lang wrote:
>>>>>
>>>>>  
>>>>>       
>>>>>
>>>>>> Hi
>>>>>> I've been using the XML tags in JSTL and found them very useful, 
>>>>>> however now I need to add an attribute to an XML element and have 
>>>>>> hit a brick wall.
>>>>>>
>>>>>> I've tried using <c:set> and EL, treating a DOM object as a bean, 
>>>>>> but the DOM interface is implementation-dependent and my 
>>>>>> implementation (xerces) doesn't lend itself to adding attributes 
>>>>>> with the simple EL view of bean properties.
>>>>>>
>>>>>> It seems to me that <x:set> needs to have a "target"attribute 
>>>>>> along the same lines as <c:set>, but accepting an XPath expression.
>>>>>> eg
>>>>>>   <x:set select="12345" 
>>>>>> target="$myRoot//myElement[position()=0]/@myAttribute" />
>>>>>> where:
>>>>>>   - select can be either an XPath expression or an immediate value.
>>>>>>   - if @myAttribute doesn't currently exist in the element then it 
>>>>>> is created.
>>>>>>
>>>>>> Does this make sense?
>>>>>> Is there a simple, portable, way of achieving this using JSTL as 
>>>>>> it stands? (Using <c:set> is not portable due to DOM being 
>>>>>> implementation dependent).
>>>>>>
>>>>>> Thanks
>>>>>> Murray

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by "Mark R. Diggory" <md...@latte.harvard.edu>.
I believe you would get the parent element of the attribute and use a 
pointer to that Node to add the attribute. Look Over DOMNodePointer for 
more details.

http://jakarta.apache.org/commons/jxpath/apidocs/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.html

-Mark

Kris Schneider wrote:

>That still doesn't seem to address the question about adding an attribute. If
>the attribute doesn't exist, you can't access it with something like
>domCtx.getPointer("root/child/@id"), right? I took a look at the API and this
>seemed to work (JSTL 1.1, Xalan 2.6.0, and Xerces 2.6.2 on TC 5.0.19):
>
><%@ page contentType="text/plain" %>
><%@ page import="org.apache.commons.jxpath.*" %>
><%@ page import="org.w3c.dom.*" %>
><%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
>
><x:parse varDom="dom">
>    <root>
>        <child>Child 1</child>
>        <child>Child 2</child>
>        <child>Child 3</child>
>    </root>
></x:parse>
>
>child:    <x:out select="$dom/root/child"/>
>child id: <x:out select="$dom/root/child/@id"/>
>
><jsp:useBean id="dom" type="org.w3c.dom.Document"/>
><%
>JXPathContext domCtx = JXPathContext.newContext(dom);
>Pointer ptr = domCtx.getPointer("root/child");
>Element elem = (Element)ptr.getNode();
>elem.setAttribute("id", "1");
>%>
>
>child:    <x:out select="$dom/root/child"/>
>child id: <x:out select="$dom/root/child/@id"/>
>
>Which produced:
>
>child:    Child 1
>child id: 
>
>child:    Child 1
>child id: 1
>
>It looks like there's also a way to add an attribute through the JXPath API, but
>you have to cast the Pointer to a NodePointer and the code's a bit uglier. Of
>course, if you're gonna drop down to Java, there are lots of other options for
>programmatically modifying DOM through XPath...
>
>Quoting "Mark R. Diggory" <md...@latte.harvard.edu>:
>
>  
>
>>You can use JXPath to manipulate the content of the DOM directly (ie 
>>without having to instantiate a whole new copied DOM object to establish 
>>your changes (as you whould have to do with XSLT).
>>
>>Say you instantiate some DOM Document object, you can use JXPath as such:
>>
>>Document doc = ....;
>>JXPathContext context = JXPathContext.newContext(doc);
>>
>>Iterator iter = context.iteratePointers("//some[xpath]");
>>while (iter.hasNext()) {
>>      Pointer pointer = (Pointer) iter.next();
>>      System.out.println("value before change: " + pointer.getValue());
>>      pointer.setValue(value);
>>      System.out.println("value after change: " + pointer.getValue());
>>}
>>
>>.. Serialize your DOM to wherever using whatever.
>>
>>Yes, by scriptable, I mean you can write your java code between <%%> or 
>><jsp:scriptlet></jsp:scriptlet>
>>
>>Maybe someday there'll be a JXPath taglibrary which would make all this 
>>all grovy in JSP.
>>
>>-Mark
>>
>>Kris Schneider wrote:
>>
>>    
>>
>>>I'm not too familiar with JXPath, and I'm sure it's useful in other
>>>      
>>>
>>contexts,
>>    
>>
>>>but I don't see how it's applicable to Murray's problem. Can it be used to
>>>      
>>>
>>add
>>    
>>
>>>an attribute to an existing element? I'm also not sure I get the point
>>>      
>>>
>>about
>>    
>>
>>>"JXPath can be scripted into a JSP". Do you mean something besides:
>>>
>>><%
>>>Foo fooCtx = (Foo)JXPathContext.newContext(myFoo);
>>>%>
>>>
>>>Quoting "Mark R. Diggory" <md...@latte.harvard.edu>:
>>>
>>> 
>>>
>>>      
>>>
>>>>This is outside the scope of the taglibrary, JSTL xml taglibrary is for 
>>>>presentation of xml content, not for its manipulation. I recommend 
>>>>looking into a package such as JXPath to accomplish manipulation of the 
>>>>content of a DOM object. the nice thing is that JXPath can be scripted 
>>>>into a JSP, Servlet or Struts Action, which gives you the fredom to move 
>>>>it out of the Presentation layer (where you probibly shouldn't be 
>>>>placing such logic).
>>>>
>>>>http://jakarta.apache.org/commons/jxpath/
>>>>
>>>>Good Luck
>>>>-Mark
>>>>
>>>>Murray Lang wrote:
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>>>>Hi
>>>>>I've been using the XML tags in JSTL and found them very useful, 
>>>>>however now I need to add an attribute to an XML element and have hit 
>>>>>a brick wall.
>>>>>
>>>>>I've tried using <c:set> and EL, treating a DOM object as a bean, but 
>>>>>the DOM interface is implementation-dependent and my implementation 
>>>>>(xerces) doesn't lend itself to adding attributes with the simple EL 
>>>>>view of bean properties.
>>>>>
>>>>>It seems to me that <x:set> needs to have a "target"attribute along 
>>>>>the same lines as <c:set>, but accepting an XPath expression.
>>>>>eg
>>>>>   <x:set select="12345" 
>>>>>target="$myRoot//myElement[position()=0]/@myAttribute" />
>>>>>where:
>>>>>   - select can be either an XPath expression or an immediate value.
>>>>>   - if @myAttribute doesn't currently exist in the element then it 
>>>>>is created.
>>>>>
>>>>>Does this make sense?
>>>>>Is there a simple, portable, way of achieving this using JSTL as it 
>>>>>stands? (Using <c:set> is not portable due to DOM being implementation 
>>>>>dependent).
>>>>>
>>>>>Thanks
>>>>>Murray
>>>>>          
>>>>>
>
>  
>



Re: Adding attributes to an XML element in JSTL

Posted by Kris Schneider <kr...@dotech.com>.
That still doesn't seem to address the question about adding an attribute. If
the attribute doesn't exist, you can't access it with something like
domCtx.getPointer("root/child/@id"), right? I took a look at the API and this
seemed to work (JSTL 1.1, Xalan 2.6.0, and Xerces 2.6.2 on TC 5.0.19):

<%@ page contentType="text/plain" %>
<%@ page import="org.apache.commons.jxpath.*" %>
<%@ page import="org.w3c.dom.*" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>

<x:parse varDom="dom">
    <root>
        <child>Child 1</child>
        <child>Child 2</child>
        <child>Child 3</child>
    </root>
</x:parse>

child:    <x:out select="$dom/root/child"/>
child id: <x:out select="$dom/root/child/@id"/>

<jsp:useBean id="dom" type="org.w3c.dom.Document"/>
<%
JXPathContext domCtx = JXPathContext.newContext(dom);
Pointer ptr = domCtx.getPointer("root/child");
Element elem = (Element)ptr.getNode();
elem.setAttribute("id", "1");
%>

child:    <x:out select="$dom/root/child"/>
child id: <x:out select="$dom/root/child/@id"/>

Which produced:

child:    Child 1
child id: 

child:    Child 1
child id: 1

It looks like there's also a way to add an attribute through the JXPath API, but
you have to cast the Pointer to a NodePointer and the code's a bit uglier. Of
course, if you're gonna drop down to Java, there are lots of other options for
programmatically modifying DOM through XPath...

Quoting "Mark R. Diggory" <md...@latte.harvard.edu>:

> 
> You can use JXPath to manipulate the content of the DOM directly (ie 
> without having to instantiate a whole new copied DOM object to establish 
> your changes (as you whould have to do with XSLT).
> 
> Say you instantiate some DOM Document object, you can use JXPath as such:
> 
> Document doc = ....;
> JXPathContext context = JXPathContext.newContext(doc);
> 
> Iterator iter = context.iteratePointers("//some[xpath]");
> while (iter.hasNext()) {
>       Pointer pointer = (Pointer) iter.next();
>       System.out.println("value before change: " + pointer.getValue());
>       pointer.setValue(value);
>       System.out.println("value after change: " + pointer.getValue());
> }
> 
> .. Serialize your DOM to wherever using whatever.
> 
> Yes, by scriptable, I mean you can write your java code between <%%> or 
> <jsp:scriptlet></jsp:scriptlet>
> 
> Maybe someday there'll be a JXPath taglibrary which would make all this 
> all grovy in JSP.
> 
> -Mark
> 
> Kris Schneider wrote:
> 
> >I'm not too familiar with JXPath, and I'm sure it's useful in other
> contexts,
> >but I don't see how it's applicable to Murray's problem. Can it be used to
> add
> >an attribute to an existing element? I'm also not sure I get the point
> about
> >"JXPath can be scripted into a JSP". Do you mean something besides:
> >
> ><%
> >Foo fooCtx = (Foo)JXPathContext.newContext(myFoo);
> >%>
> >
> >Quoting "Mark R. Diggory" <md...@latte.harvard.edu>:
> >
> >  
> >
> >>This is outside the scope of the taglibrary, JSTL xml taglibrary is for 
> >>presentation of xml content, not for its manipulation. I recommend 
> >>looking into a package such as JXPath to accomplish manipulation of the 
> >>content of a DOM object. the nice thing is that JXPath can be scripted 
> >>into a JSP, Servlet or Struts Action, which gives you the fredom to move 
> >>it out of the Presentation layer (where you probibly shouldn't be 
> >>placing such logic).
> >>
> >>http://jakarta.apache.org/commons/jxpath/
> >>
> >>Good Luck
> >>-Mark
> >>
> >>Murray Lang wrote:
> >>
> >>    
> >>
> >>>Hi
> >>>I've been using the XML tags in JSTL and found them very useful, 
> >>>however now I need to add an attribute to an XML element and have hit 
> >>>a brick wall.
> >>>
> >>>I've tried using <c:set> and EL, treating a DOM object as a bean, but 
> >>>the DOM interface is implementation-dependent and my implementation 
> >>>(xerces) doesn't lend itself to adding attributes with the simple EL 
> >>>view of bean properties.
> >>>
> >>>It seems to me that <x:set> needs to have a "target"attribute along 
> >>>the same lines as <c:set>, but accepting an XPath expression.
> >>>eg
> >>>    <x:set select="12345" 
> >>>target="$myRoot//myElement[position()=0]/@myAttribute" />
> >>>where:
> >>>    - select can be either an XPath expression or an immediate value.
> >>>    - if @myAttribute doesn't currently exist in the element then it 
> >>>is created.
> >>>
> >>>Does this make sense?
> >>>Is there a simple, portable, way of achieving this using JSTL as it 
> >>>stands? (Using <c:set> is not portable due to DOM being implementation 
> >>>dependent).
> >>>
> >>>Thanks
> >>>Murray

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by "Mark R. Diggory" <md...@latte.harvard.edu>.
You can use JXPath to manipulate the content of the DOM directly (ie 
without having to instantiate a whole new copied DOM object to establish 
your changes (as you whould have to do with XSLT).

Say you instantiate some DOM Document object, you can use JXPath as such:

Document doc = ....;
JXPathContext context = JXPathContext.newContext(doc);

Iterator iter = context.iteratePointers("//some[xpath]");
while (iter.hasNext()) {
      Pointer pointer = (Pointer) iter.next();
      System.out.println("value before change: " + pointer.getValue());
      pointer.setValue(value);
      System.out.println("value after change: " + pointer.getValue());
}

.. Serialize your DOM to wherever using whatever.

Yes, by scriptable, I mean you can write your java code between <%%> or 
<jsp:scriptlet></jsp:scriptlet>

Maybe someday there'll be a JXPath taglibrary which would make all this 
all grovy in JSP.

-Mark

Kris Schneider wrote:

>I'm not too familiar with JXPath, and I'm sure it's useful in other contexts,
>but I don't see how it's applicable to Murray's problem. Can it be used to add
>an attribute to an existing element? I'm also not sure I get the point about
>"JXPath can be scripted into a JSP". Do you mean something besides:
>
><%
>Foo fooCtx = (Foo)JXPathContext.newContext(myFoo);
>%>
>
>Quoting "Mark R. Diggory" <md...@latte.harvard.edu>:
>
>  
>
>>This is outside the scope of the taglibrary, JSTL xml taglibrary is for 
>>presentation of xml content, not for its manipulation. I recommend 
>>looking into a package such as JXPath to accomplish manipulation of the 
>>content of a DOM object. the nice thing is that JXPath can be scripted 
>>into a JSP, Servlet or Struts Action, which gives you the fredom to move 
>>it out of the Presentation layer (where you probibly shouldn't be 
>>placing such logic).
>>
>>http://jakarta.apache.org/commons/jxpath/
>>
>>Good Luck
>>-Mark
>>
>>Murray Lang wrote:
>>
>>    
>>
>>>Hi
>>>I've been using the XML tags in JSTL and found them very useful, 
>>>however now I need to add an attribute to an XML element and have hit 
>>>a brick wall.
>>>
>>>I've tried using <c:set> and EL, treating a DOM object as a bean, but 
>>>the DOM interface is implementation-dependent and my implementation 
>>>(xerces) doesn't lend itself to adding attributes with the simple EL 
>>>view of bean properties.
>>>
>>>It seems to me that <x:set> needs to have a "target"attribute along 
>>>the same lines as <c:set>, but accepting an XPath expression.
>>>eg
>>>    <x:set select="12345" 
>>>target="$myRoot//myElement[position()=0]/@myAttribute" />
>>>where:
>>>    - select can be either an XPath expression or an immediate value.
>>>    - if @myAttribute doesn't currently exist in the element then it 
>>>is created.
>>>
>>>Does this make sense?
>>>Is there a simple, portable, way of achieving this using JSTL as it 
>>>stands? (Using <c:set> is not portable due to DOM being implementation 
>>>dependent).
>>>
>>>Thanks
>>>Murray
>>>      
>>>
>
>  
>



Re: Adding attributes to an XML element in JSTL

Posted by Kris Schneider <kr...@dotech.com>.
I'm not too familiar with JXPath, and I'm sure it's useful in other contexts,
but I don't see how it's applicable to Murray's problem. Can it be used to add
an attribute to an existing element? I'm also not sure I get the point about
"JXPath can be scripted into a JSP". Do you mean something besides:

<%
Foo fooCtx = (Foo)JXPathContext.newContext(myFoo);
%>

Quoting "Mark R. Diggory" <md...@latte.harvard.edu>:

> This is outside the scope of the taglibrary, JSTL xml taglibrary is for 
> presentation of xml content, not for its manipulation. I recommend 
> looking into a package such as JXPath to accomplish manipulation of the 
> content of a DOM object. the nice thing is that JXPath can be scripted 
> into a JSP, Servlet or Struts Action, which gives you the fredom to move 
> it out of the Presentation layer (where you probibly shouldn't be 
> placing such logic).
> 
> http://jakarta.apache.org/commons/jxpath/
> 
> Good Luck
> -Mark
> 
> Murray Lang wrote:
> 
> > Hi
> > I've been using the XML tags in JSTL and found them very useful, 
> > however now I need to add an attribute to an XML element and have hit 
> > a brick wall.
> >
> > I've tried using <c:set> and EL, treating a DOM object as a bean, but 
> > the DOM interface is implementation-dependent and my implementation 
> > (xerces) doesn't lend itself to adding attributes with the simple EL 
> > view of bean properties.
> >
> > It seems to me that <x:set> needs to have a "target"attribute along 
> > the same lines as <c:set>, but accepting an XPath expression.
> > eg
> >     <x:set select="12345" 
> > target="$myRoot//myElement[position()=0]/@myAttribute" />
> > where:
> >     - select can be either an XPath expression or an immediate value.
> >     - if @myAttribute doesn't currently exist in the element then it 
> > is created.
> >
> > Does this make sense?
> > Is there a simple, portable, way of achieving this using JSTL as it 
> > stands? (Using <c:set> is not portable due to DOM being implementation 
> > dependent).
> >
> > Thanks
> > Murray

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Adding attributes to an XML element in JSTL

Posted by "Mark R. Diggory" <md...@latte.harvard.edu>.
This is outside the scope of the taglibrary, JSTL xml taglibrary is for 
presentation of xml content, not for its manipulation. I recommend 
looking into a package such as JXPath to accomplish manipulation of the 
content of a DOM object. the nice thing is that JXPath can be scripted 
into a JSP, Servlet or Struts Action, which gives you the fredom to move 
it out of the Presentation layer (where you probibly shouldn't be 
placing such logic).

http://jakarta.apache.org/commons/jxpath/

Good Luck
-Mark

Murray Lang wrote:

> Hi
> I've been using the XML tags in JSTL and found them very useful, 
> however now I need to add an attribute to an XML element and have hit 
> a brick wall.
>
> I've tried using <c:set> and EL, treating a DOM object as a bean, but 
> the DOM interface is implementation-dependent and my implementation 
> (xerces) doesn't lend itself to adding attributes with the simple EL 
> view of bean properties.
>
> It seems to me that <x:set> needs to have a "target"attribute along 
> the same lines as <c:set>, but accepting an XPath expression.
> eg
>     <x:set select="12345" 
> target="$myRoot//myElement[position()=0]/@myAttribute" />
> where:
>     - select can be either an XPath expression or an immediate value.
>     - if @myAttribute doesn't currently exist in the element then it 
> is created.
>
> Does this make sense?
> Is there a simple, portable, way of achieving this using JSTL as it 
> stands? (Using <c:set> is not portable due to DOM being implementation 
> dependent).
>
> Thanks
> Murray
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>



Re: Adding attributes to an XML element in JSTL

Posted by Kris Schneider <kr...@dotech.com>.
It sounds like you'd be better off using XSLT and the <x:transform> tag...

Quoting Murray Lang <mu...@metoceanengineers.com>:

> Hi
> I've been using the XML tags in JSTL and found them very useful, however 
> now I need to add an attribute to an XML element and have hit a brick wall.
> 
> I've tried using <c:set> and EL, treating a DOM object as a bean, but the 
> DOM interface is implementation-dependent and my implementation (xerces) 
> doesn't lend itself to adding attributes with the simple EL view of bean 
> properties.
> 
> It seems to me that <x:set> needs to have a "target"attribute along the 
> same lines as <c:set>, but accepting an XPath expression.
> eg
> 	<x:set select="12345" 
> target="$myRoot//myElement[position()=0]/@myAttribute" />
> where:
> 	- select can be either an XPath expression or an immediate value.
> 	- if @myAttribute doesn't currently exist in the element then it is
> created.
> 
> Does this make sense?
> Is there a simple, portable, way of achieving this using JSTL as it stands? 
> (Using <c:set> is not portable due to DOM being implementation dependent).
> 
> Thanks
> Murray

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org