wood burning stoves 2.0*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in retrieving attribute value