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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Java in XSLT" Watch "Java in XSLT" New topic
Author

Java in XSLT

Monika Nencheva
Greenhorn

Joined: Jul 14, 2010
Posts: 3
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: 18129
    
    8

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

Joined: Jul 14, 2010
Posts: 3
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://aspose.com/file-tools
 
subject: Java in XSLT
 
Similar Threads
Why this is not working.......
xsl dynamic extraction of xml data help
tags
xsl dynamic extraction of xml data help
dynamic xml output based on user input