aspose file tools
The moose likes XML and Related Technologies and the fly likes Java in XSLT Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "Java in XSLT" Watch "Java in XSLT" New topic
Author

Java in XSLT

Monika Nencheva
Greenhorn

Joined: Jul 14, 2010
Posts: 2
This is my xml file:
<users>
<user>
<username>mshelly</username>
<password>msh9568745</password>
<person sex="male">
<title>Mr</title>
<lastname>Shelly</lastname>
<firstname>Misho</firstname>
<nationality>Australian</nationality>
<birthdate>1971-11-01</birthdate>
</person>
<email>mshelly@mymail.com</email>
<mobile>+61356986475631</mobile>
<fax>+6145821255858</fax>
<address>
<home>
<country>Australia</country>
<city>Sydney</city>
<street>GreenMile</street>
<number>17</number>
<postalcode>658</postalcode>
</home>
<work>
<country>Australia</country>
<city>Hobart</city>
<street>West Bird</street>
<number>3</number>
<postalcode>654</postalcode>
</work>
</address>
<preference>None</preference>
</user>....................
And this is my xslt file :
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Personal Information</h2>
<table border="2">
<tr bgcolor="#009995557">
<th>username</th>
<th>lastname</th>
<th>firstname</th>
<th>mail</th>
<th>mobile</th>
<th>fax</th>
</tr>
<xsl:for-each select="users/user/person[starts-with(lastname,'Iva')]/..">
<xsl:sort select="username"/>
<tr>
<td><xsl:value-of select="username"/></td>
<td><xsl:value-of select="person/lastname"/></td>
<td><xsl:value-of select="person/firstname"/></td>
<td><xsl:value-of select="email"/></td>
<td><xsl:value-of select="mobile"/></td>
<td><xsl:value-of select="fax"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

How can I replace this "<xsl:for-each select="users/user/person[starts-with(lastname,'Iva')]/..">" with some java code so that when I type from the output some string it will find the correct user by this string?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16483
    
    2

Why Java code? Why not just pass the desired string to the transform as a parameter?
Monika Nencheva
Greenhorn

Joined: Jul 14, 2010
Posts: 2
Thank you for the answer. Well, because I have to adapt a Java program to it. And I don't know exactly how to do it.
Thanks!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Java in XSLT
 
Similar Threads
xsl dynamic extraction of xml data help
xsl dynamic extraction of xml data help
tags
dynamic xml output based on user input
Why this is not working.......