jQuery in Action, 3rd edition
The moose likes JSP and the fly likes namespaces, rdf and forEach Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "namespaces, rdf and forEach" Watch "namespaces, rdf and forEach" New topic
Author

namespaces, rdf and forEach

mik mak
Greenhorn

Joined: Mar 25, 2008
Posts: 3
Hello,

I hope someone can help me with this one. I'm rather new to jstl to maybe it's a no-problem, but anyway I'm stuck.
I have this foxmarks.xml file:

=== foxmarks.xml ===============================================================

=== foxmarks.xml =======================================================

I've shortened it up a bit (...)
It contains information about my firefox bookmarks that I want to present in a webpage.
So I'm trying to read the data with a c:forEach but I don't know how to handle the namespace prefixes.
This is what I've tried:

=== fox.jsp ====================================================================

=== fox.jsp ============================================================

1) The above code gives zero output and no errors. Maybe it can't find any "Folder" tags?

2) So I try to add the namespace
<x:forEach var="n" select="$doc//NC:Folder">
<xut select="$n/NC:URL" />
It doesn't work either.
javax.xml.transform.TransformerException: Prefix must resolve to a namespace: NC

3) If I try to define it as a namespace using the definition from the foxmarks.xml file:
<%@ taglib prefix="NC" uri="http://home.netscape.com/WEB-rdf#" %>
org.apache.jasper.JasperException: The absolute uri: http://home.netscape.com/WEB-rdf# cannot be resolved in either web.xml or the jar files deployed with this application ...
I thought a namespace was just a definition, not something physically existing.

Thank you for your patience.
Can someone help me please
I don't know where the problem is.
Is it the namespace, is it rdf?
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 596
    
    1

I don't see you have created tld file.You need to create tld file(for ex. a.tld)in your web-inf folder.

Create tld first and then ask for farther explanation.Then it would be
easier to help you.


Most of the programming problems can't be solved because you don't know what the exact problem is.
Defining your problem correctly leads you to the right solution.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63350
    
  70

Why would he need to write a tld?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 596
    
    1

Well, When I had problem like that I did so and it was solved.
May it could be hallucination,though. :P

Make the change like on your xml file according to your uri specification.


Noteon't put code exactly I did.please specify you uri on the tag.

[ March 26, 2008: Message edited by: omi sharma ]
[ March 26, 2008: Message edited by: omi sharma ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63350
    
  70

No. Nothing ever need be added to the web.xml in order to use the JSTL.
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 596
    
    1

Mr. Bear , I am really confused with this problem but I will still try to help,even if I am beginner.

Author :You can have some possible solutions but I am not sure because
I am beginner too.I am waiting for experts to reply.

1)put this on your fox.jsp<%@ page isELIgnored="false" %>
2)To load the properties file in jsp, use <fmt:..> to load the bundle and store the message value to variable.
<fmt:setBundle var="mybundle" basename="myfile"/>
<fmt:message var="names" key="fileName" bundle="${mybundle}"/>

Then use <c:forTokens> to split and loop the list. e.g.
<c:forTokens var="file" items="${names}" delims=",">
<cut value="${file}"/>
</c:forTokens>
3)use tomcat 6 and put this on your jsp
<%@taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
[ March 27, 2008: Message edited by: omi sharma ]
mik mak
Greenhorn

Joined: Mar 25, 2008
Posts: 3
Thanks for your help guys

I was more or less giving up:
* I saw how XUL reads and treats rdf files xulplanet.com but it doesn't seems to render HTML.
* I was going to delete the prefixes with something like XSLT before parsing the data

Then I saw your replies.
As for the TLD. I don't know what a TLD is nor what it can do for me. But if you say I don't need it I won't bother.

I'll try to use c:forToken, I'll let you know soon

As for the other two ideas,
What do they mean?
1) isELIgnored I understand but I don't think EL is ignored. What makes you says it is?
2) How can a properties file be of use? Should I try to load my foxmarks.xml as a properties file?

Once again thanks for your help
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 596
    
    1

you have to set elIgnored false sometimes ,even it is by default false.
I had some problem ,relating to it so I told you to do so.
Sir, I am new to JSTL.But I have not really got what exactly you want to do?
you want to forward the xml file ? or you want to use it as template file?
or what else? :P
please clarify this ASAP.
[ March 28, 2008: Message edited by: omi sharma ]
mik mak
Greenhorn

Joined: Mar 25, 2008
Posts: 3
I'm trying to transform the foxmarks.xml file above in a HTML page displaying my bookmarks.
Put simply I want to loop through the foxmarks file and display every <NC:Bookmark> entry as a URL.
For example the last entry in the foxmarks file would yield:
<a href="http://en.wikipedia.org/wiki/Main_Page">Wikipedia</a>
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 596
    
    1

I think your problem is more logical than syntactical.
Please wait for our experts to reply.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: namespaces, rdf and forEach
 
It's not a secret anymore!