Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jstl and xml attributes

Status
Not open for further replies.

Sarky78

Programmer
Oct 19, 2000
878
GB
Hi all

I hope someone here is going to be able help with this one, complete jsp newbie.

I've inherited a project that is using jstl and xml to perform data output. I need to be able to add an attribute to a node, but when i do the whole thing crashes, this is without making any change to the jstl. the xml document parses in other languages ok, so it is valid, but just goes wrong with jsp.

Does jstl - i think we are using 1.0 - support attributes?

this is the structure of the document:

Code:
<Collection>
  <Pages pageid="1">
    <Page>
    </Page>
  </Pages>
</Collection>

Thanks

Tony
 
Let me confirm something first. You want to use JSTL tanglib to
do something.
If collection does not have the attribute pageid in JSTL, you cannot add to it. You can look at the tld files in WEB-INF or search for documentation for your version of JSTL.
You can solve your problem in the following ways.
1) write your own taglib. You need to write the Java file and support tld file... You can search for tutorial on web.
2) search for free taglib on Internet supporting paging.
3) search if newer version of JSTL support paging.
 

Not quite, JSTL is being used to parse and read an xml document. I want to add a new attribute to the XML document that is read, and then output it using jstl. It is nothing to do with paging, all I want to do is to output the value contained within the pageid attribute.

My understanding is that i won't need to change the underlying taglib as all I am doing is outputting a value from the xml.

when i try to do this using the code someone else has written i get an error

So, the question is, how do i output an xml attribute using the above structure within jstl/jsp?

Thanks

Tony
 
I use (+jstl +parse +xml) as parameter in The technique used is similar to xslt. You may need to know the
way to select an attribute from a xml file.

You may read about using xslt in Java
I prefer to use xslt in Java. It is more flexible but it reqires more programming. Please use utf-8 as encoding in xml for using xslt in Java.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top