Validate or unit test for TLD files?

D

Daniel Pitts

We have a tag lib descriptor file, and when we tried to integrate it we
found a problem. Is there an easy way to validate and/or unit test a
TLD file?

Thanks,
Daniel.
 
R

Roedy Green

We have a tag lib descriptor file, and when we tried to integrate it we
found a problem. Is there an easy way to validate and/or unit test a
TLD file?

I presume you mean a file like this?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag
Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>j2eeforum</shortname>
<info>Sample Tag library Created for j2eeforum </info>
<!-Tag Starts -->
<tag>
<name>ipaddress</name>
<tagclass>j2eeforum.IpAddress </tagclass>
<bodycontent>empty</bodycontent>
<info>
This is a example tag for displaying ipaddress.
</info>
<attribute>
<name>target</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>

You could feed an example into Stylus Studio and it will generate you
an XSD for it. Polish the XSD manually, and you have a syntax checker.

See http://mindprod.com/jgloss/xsd.html
--
Roedy Green Canadian Mind Products
http://mindprod.com
When you were a child, if you did your own experiment
to see if it was better to put to cocoa into your cup first
or the hot milk first, then you likely have the programmer gene..
 
D

Daniel Pitts

I presume you mean a file like this?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag
Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>j2eeforum</shortname>
<info>Sample Tag library Created for j2eeforum</info>
<!-Tag Starts -->
<tag>
<name>ipaddress</name>
<tagclass>j2eeforum.IpAddress</tagclass>
<bodycontent>empty</bodycontent>
<info>
This is a example tag for displaying ipaddress.
</info>
<attribute>
<name>target</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>

You could feed an example into Stylus Studio and it will generate you
an XSD for it. Polish the XSD manually, and you have a syntax checker.

See http://mindprod.com/jgloss/xsd.html
Syntax is one thing, but not the only thing that contributes to
validity. Classes need to be spelled correctly, functions need to have
the correct signatures, etc...
 
R

Roedy Green

If possible, I'd like to validate these outside of having a J2EE
container running.

What kind of errors won't show up by just using the TLD?
Surely you are not the first person to encounter this problem.
--
Roedy Green Canadian Mind Products
http://mindprod.com
When you were a child, if you did your own experiment
to see if it was better to put to cocoa into your cup first
or the hot milk first, then you likely have the programmer gene..
 
D

Daniel Pitts

What kind of errors won't show up by just using the TLD?
Surely you are not the first person to encounter this problem.
That's the problem, I want to find the errors before use. This is in a
library package separated from its uses.
 
A

Arved Sandstrom

What kind of errors won't show up by just using the TLD?
Surely you are not the first person to encounter this problem.

I think (repeated) app deployments in a container _will_ winkle out all
the problems. That's been my experience. But it is quite time-consuming,
which is what I think Daniel is getting at.

What I do for Facelets taglib descriptor files *and* the XHTML pages
that use them - which are the only variant I am interested in - is run a
few scripts I've written myself. It's not particularly complicated bash
or Windows Powershell logic.

On a related note I've found myself doing similar things for validating
persistence.xml config files.

AHS
 
A

Arne Vajhøj

We have a tag lib descriptor file, and when we tried to integrate it we
found a problem. Is there an easy way to validate and/or unit test a TLD
file?

I can not see any other way than writing a unit test JSP
page, deploy it and TLD+JAR and then unit test the output
from the JSP page.

It is very debatable whether that is really *unit* testing,
but ...

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top