Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 22nd, 2015, 12:29 AM
Registered User
 
Join Date: Dec 2015
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Post transform xml to html with through xslt

Good Day,
I am unable to transform below xml to html format.

Input XML

<?xml version="1.0" encoding="UTF-8"?>
<L7j:jdbcQueryResult xmlns:L7j="http://ns.l7tech.com/2012/08/jdbc-query-result">
<L7j:row>
<L7j:col name="name" type="java.lang.String">Test-1</L7j:col>
<L7j:col name="comment" ><![CDATA[NULL]]></L7j:col><L7j:col name="version" type="java.lang.Integer">23</L7j:col></L7j:row>
<L7j:row><L7j:col name="name" type="java.lang.String">Test-2</L7j:col><L7j:col name="comment" ><![CDATA[NULL]]></L7j:col><L7j:col name="version" type="java.lang.Integer">18</L7j:col></L7j:row>
</L7j:jdbcQueryResult>

OutPut :Format in HTML

Example:In HTML table format

Name version comment
----------------------------------
Test-1 23 null
Test-2 18 text-233

It will be great if any one can provide me xsl ,how to transform?

Thanks in advance
Vishwas
 
Old December 22nd, 2015, 03:57 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Top post in this forum gives some great hints and tips on making a great post:

Hints for a good XSLT post

Specifically - what have you tried so far - what does your XSLT look like.

Also read the bit about namespaces, as you are using them.

Sam
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old December 22nd, 2015, 05:25 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

To add what Sam says, we're happy to help if we know what your problem is, but we're not here to do your job for you.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old December 22nd, 2015, 10:57 PM
Registered User
 
Join Date: Dec 2015
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs down

#samjudson:Thanks

#mhkay:
I am not asking you to do my job.I will solve this issue my self.
Thanks ur response.
 
Old December 23rd, 2015, 11:22 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Quote:
It will be great if any one can provide me xsl ,how to transform?
You did just ask for the XSLT, without showing us what you've tried before, implying you want us to do the work for you.

If you want us to help you we need to know what you know so far, where you might be making mistakes or not fully understanding something.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old December 27th, 2015, 10:12 PM
Registered User
 
Join Date: Dec 2015
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Sam,
Please find below my code:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:L7j="http://ns.l7tech.com/2012/08/jdbc-query-result">
 
<xsl:template match="/">
  <html>
  <body>
  <h2>My CD Collection</h2>
  <table border="1">
    <tr bgcolor="#9acd32">
      <th>Name</th>
      <th>Comment</th>
      <th>Version</th>
    </tr>
    <xsl:for-each select="L7j:jdbcQueryResult/L7j:row/L7j:col">
    
 
        <tr>
<xsl:if test="@name ='name'">  
            <td><xsl:value-of select="."/></td>
         
</xsl:if>  
  <xsl:if test="@name ='comment'">  
            <td><xsl:value-of select="."/></td>
         
</xsl:if>  
<xsl:if test="@name ='version'">  
            <td><xsl:value-of select="."/></td>
         
</xsl:if>  
           
  
</tr>
    </xsl:for-each>
  </table>
  </body>
  </html>
</xsl:template>
 
</xsl:stylesheet>
Input xml is:
<?xml version="1.0" encoding="UTF-8"?>
<L7j:jdbcQueryResult xmlns:L7j="http://ns.l7tech.com...bc-query-result">
<L7j:row>
<L7j:col name="name" type="java.lang.String">Policy for service #0b8bab6913cc588557b6973e94d1bfdd, WSTrustSoapService</L7j:col>
<L7j:col name="comment" ><![CDATA[NULL]]></L7j:col><L7j:col name="version" type="java.lang.Integer">18</L7j:col></L7j:row>

<L7j:row><L7j:col name="name" type="java.lang.String">Policy for service #0b8bab6913cc588557b6973e94d5893d, UUPRStub</L7j:col><L7j:col name="comment" ><![CDATA[NULL]]></L7j:col><L7j:col name="version" type="java.lang.Integer">16</L7j:col></L7j:row><L7j:row><L7j:col name="name" type="java.lang.String">Policy for service #0b8bab6913cc588557b6973e94d7900f, smstest</L7j:col><L7j:col name="comment" ><![CDATA[NULL]]></L7j:col><L7j:col name="version" type="java.lang.Integer">6</L7j:col></L7j:row>

</L7j:jdbcQueryResult>

expecting outPut:

Name comment version
----------------------------------------

test test123 23

Last edited by [email protected]; January 5th, 2016 at 03:17 AM..
 
Old January 11th, 2016, 04:33 AM
Registered User
 
Join Date: Dec 2015
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Sam,
Did you get the chance to check my code.





Similar Threads
Thread Thread Starter Forum Replies Last Post
xml flat file transform to nested tag xml using xslt transform adsingh XSLT 0 August 7th, 2013 01:27 PM
how to actually transform an XML with XSLT? ovlique BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0 2 June 27th, 2010 03:06 PM
need help with this html to xml transform sahori79 XSLT 4 August 13th, 2009 07:07 AM
transform a xml to a html table robert_trudel_fr XSLT 3 December 3rd, 2006 02:16 PM
XSLT read through XML to transform another XML dendenx2 XSLT 8 July 7th, 2005 08:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.