This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes problem in retrieving attribute value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "problem in retrieving attribute value" Watch "problem in retrieving attribute value" New topic
Author

problem in retrieving attribute value

Priyadarshini Anand
Greenhorn

Joined: Jun 02, 2004
Posts: 22
Hi,

I am writing XSLT for the following XML file

<TestReport>

<TestCaseReport result="pass" sequence="1" id="3A4" xmlns="http://oracle/tipqa/fw/b2b/xmlmodel/testreport">
<reportData state="started"/>
</TestCaseReport>

<TestCaseReport result="fail" sequence="2" id="3A6" xmlns="http://oracle/tipqa/fw/b2b/xmlmodel/testreport">
<reportData state="started"/>
</TestCaseReport>

</TestReport>

XSLT is as follows :
<html>
<body>
<table>
<xsl:for-each select="/TestReport/TestCaseReport">
<tr>
<td><xsl:value-of select="@sequence"/></td>
<td><xsl:value-of select="@id"/></td>
<td><xsl:value-of select="@result"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>

XSLT is not displaying the table.But if i will remove xmlns attribute of TestCaseReport tag then the table is displayed.


please help me to solve this problem.Without removing xmlns attribute of TestCaseReport tag how to display the table
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
You can try adding /{http://oracle/tipqa/fw/b2b/xmlmodel/testreport}TestReport /{http://oracle/tipqa/fw/b2b/xmlmodel/testreport}TestCaseReport
but its like
So try adding the namespace to the XSLT stylesheet like
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tr="http://oracle/tipqa/fw/b2b/xmlmodel/testreport"
...
</xsl:stylesheet>

then you can access it like
/tr:testReport/tr:TestReport

Will that help you to get started ?


Spritle Software Blogs
Priyadarshini Anand
Greenhorn

Joined: Jun 02, 2004
Posts: 22
thankyou,Second approach is working, though in first some problem i have.
Actually what project i am developing ,the first approach u said looks more suitable as there are many xml files accessing the same XSL file. so xmlns attribute will be different in different XML that i should retrieve using @.I hope u understood what I want to say.pl help me

Thanx,
Priya
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem in retrieving attribute value
 
Similar Threads
Namespace problem ?
attributes....
how to mimic a valign="top" call?
Create a hardcopy of moelholm.com SCEA mock test
Keyword xsl:output may not be used here.