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 Felipe Leme <t5...@sneakemail.com> on 2003/07/31 04:38:17 UTC
XML help
Hi all,
I'm having some trouble using the XML tags to print elements of a document
that uses a DTD (from xmlresume).
The "normal" xml document has the following structure:
<!DOCTYPE resume PUBLIC "-//Sean Kelly//DTD Resume 1.5.1//EN"
"../dtd/resume.dtd">
<resume xmlns="http://xmlresume.sourceforge.net/resume/0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="felipeal">
Using this structure, I can do the XSLT transformation, but can't get the name
of the elements using <x:out>.
It has to be something related to the xmlns stuff, because the <x:out> would
work if:
1.The DTDs are removed
2.The xmlns declarations are removed from both the .xml and the .dtd
Anyway, if I use one of theses aproaches, then the <x:transform> doesn't work
(it only works with the full DTD/XML).
So, my question is: I'm missing something (as I'm not a XML expert :) or is it
a bug? If it is a bug, I could take a look on the code and try to debug it,
but I'd like to be sure before I start that process..
Felipe
PS: here are some code fragments (all files are available at
http://felipeal.net/teste/jstl/ - I might be deploying the jsp files later on
that site)
testBug.jsp
--------------
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<c:set var="request" value="${pageContext.request}"/>
<c:set var="baseURL"
value="${request.scheme}://${request.serverName}:${request.serverPort}${request.contextPath}"/>
<%-- this is the code that works, as it doesn't use the DTD --%>
<x:parse var="docNoDTD">
<resume id="felipeal">
<header>
<name>
<firstname>Felipe</firstname>
<surname>Leme</surname>
</name>
</header>
</resume>
</x:parse>
<x:set var="name" select="$docNoDTD/resume/header/name"/>
Name (noDTD): <x:out select="$name/firstname"/> <x:out
select="$name/surname"/>
<br><br>
<%-- this is the code that doesn't work --%>
<x:parse var="docDTD" systemId="${baseURL}/xml/resume.xml">
<!DOCTYPE resume PUBLIC "-//Sean Kelly//DTD Resume 1.5.1//EN"
"../dtd/resume.dtd">
<resume xmlns="http://xmlresume.sourceforge.net/resume/0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="felipeal">
<header>
<name>
<firstname>felipe</firstname>
<surname>leme</surname>
</name>
</header>
</resume>
</x:parse>
<x:set var="nameDTD" select="$docDTD/resume/header/name"/>
Name (DTD): <x:out select="$nameDTD/firstname"/> <x:out
select="$nameDTD/surname"/>
<br><br>
<%-- this code works too, but I had to strip the xmlns stuff --%>
<x:parse var="docDTD2" systemId="${baseURL}/xml/resume2.xml">
<!DOCTYPE resume PUBLIC "-//Sean Kelly//DTD Resume 1.5.1//EN"
"../dtd/resume2.dtd">
<resume id="felipeal">
<header>
<name>
<firstname>FELIPE</firstname>
<surname>LEME</surname>
</name>
</header>
</resume>
</x:parse>
<x:set var="nameDTD2" select="$docDTD2/resume/header/name"/>
Name (DTD2): <x:out select="$nameDTD2/firstname"/> <x:out
select="$nameDTD2/surname"/>
<br><br>
Proof that the document was parsed:
<x:forEach var="element" select="$docDTD//">
element:<x:out select="$element"/><br>
</x:forEach>
OUTPUT
-----------
Name (noDTD): Felipe Leme
Name (DTD):
Name (DTD2): FELIPE LEME
Proof that the document was parsed: element:
element: felipe leme
element:
element: felipe leme
element:
element:
element: felipe leme
element:
element:
element:felipe
element:
element:leme
element:
element:felipe
element:leme
fragments of resume.dtd (original dtd)
----------------------------------------------
<!ELEMENT resume (docpath?, header?, (%sections;)*, lastModified?,
copyright?)>
<!ATTLIST resume id ID #IMPLIED
xmlns CDATA #FIXED "http://xmlresume.sourceforge.net/resume/0.0"
xmlns:xsi CDATA #FIXED "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation CDATA #IMPLIED>
fragments of resume2.dtd (modified dtd)
-------------------------------------------------
<!ELEMENT resume (docpath?, header?, (%sections;)*, lastModified?,
copyright?)>
<!ATTLIST resume id ID #IMPLIED>
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org