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 April 30th, 2009, 03:57 AM
Authorized User
 
Join Date: Dec 2005
Posts: 71
Thanks: 10
Thanked 0 Times in 0 Posts
Default Drag attribute and elements to generate HTML database tables

HI All,

Here is one more help request; Drag all the attribute and element values and generate separate Table below as like data base below same transformed files.

Input file:

<ref type="Test1.2">Test batting 1.2</ref>

Output file:

Normal transformation
<reference>Test batting 1.2</reference>

Bottom of the same file
<tr><td>Test1.2</td><td>Test batting 1.2</td></tr>

Any help would be grateful!
__________________
Thanks,
Rocxy.
 
Old April 30th, 2009, 04:09 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>Drag all the attribute and element values and generate separate Table below as like data base below same transformed files.

Please read again what you wrote. Tell me, if someone gave you that as a statement of requirements and told you to implement it, how would you react? It's completely incoherent.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old April 30th, 2009, 05:20 AM
Authorized User
 
Join Date: Dec 2005
Posts: 71
Thanks: 10
Thanked 0 Times in 0 Posts
Default

Here you go with clear statement: Get allthe element data and attribute data from the element "<ref>" and process two result during transformation.


1. Normal transformation
<reference>Test batting 1.2</reference>


and the other in the same file at the bottom as a separate table.

2. Bottom of the same file

<table>

<tr><td>Test1.2</td><td>Test batting 1.2</td></tr>

</table>


I regret for the confusion - If still this is ambiguous kindly help me to improve by reply.

Kay thanks for your quick response - I am Happy that some one is there to correct my errors instead going with out responding it.
__________________
Thanks,
Rocxy.
 
Old April 30th, 2009, 05:38 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

Try this:
Code:
<xsl:template match="ref">
<reference><xsl:value-of select="."></xsl:value-of></reference>
<table>
<tr><td><xsl:value-of select="@type"></xsl:value-of></td><td><xsl:value-of select="."></xsl:value-of></td></tr>
</table>
</xsl:template>

__________________
Rummy
The Following User Says Thank You to mrame For This Useful Post:
ROCXY (April 30th, 2009)
 
Old April 30th, 2009, 05:56 AM
Authorized User
 
Join Date: Dec 2005
Posts: 71
Thanks: 10
Thanked 0 Times in 0 Posts
Default

Thanks for your reply,

But all the first transformation will be in different location of the file and second transformation should be at the bottom of the same file separately (i.e.) all element and attribute values will be looked like database at the bottom of the output file.

Input:
<para>Setting the buffer-specific variable auto-indent nonzero <ref type="Test1.2">Test batting 1.2</ref>.........indents depends on the current mode <ref type="Live6.2">Live batting 6.2</ref></para>


Output:
<p>Setting the buffer-specific variable auto-indent nonzero <reference>Test batting 1.2</reference>.........indents depends on the current mode <reference>Live batting 6.2</reference></p>
...........
...........
............
<h3>Table</h3>
<table>
<tr><td>Test1.2</td><td>Test batting 1.2</td></tr>
<tr><td>Live6.2</td><td>Live batting 6.2</td></tr>
</table>
__________________
Thanks,
Rocxy.
 
Old April 30th, 2009, 06:06 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

With <para> as the top most element, try the below code:

Code:
<xsl:template match="para">
<p>
<xsl:apply-templates></xsl:apply-templates>
</p>
<xsl:if test="//ref">
<h3>Table</h3>
<table>
<xsl:for-each select="//ref">
<tr><td><xsl:value-of select="@type"></xsl:value-of></td><td><xsl:value-of select="."></xsl:value-of></td></tr>
</xsl:for-each>
</table>
</xsl:if>
</xsl:template>

<xsl:template match="ref">
<reference><xsl:value-of select="."></xsl:value-of></reference>
</xsl:template>
__________________
Rummy
The Following User Says Thank You to mrame For This Useful Post:
ROCXY (April 30th, 2009)
 
Old April 30th, 2009, 06:15 AM
Authorized User
 
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 3 Times in 3 Posts
Default Try This

<xsl:template match="/">
<xsl:apply-templates/>
<xsl:for-each select="//ref">
<xsl:text>&#xA;</xsl:text>
<xsl:element name="tr">
<xsl:element name="td">
<xsl:value-of select="@type"/>
</xsl:element>
<xsl:element name="td">
<xsl:apply-templates select="."/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:template>


<xsl:template match="ref">
<xsl:element name="reference">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
__________________
Thanks,
Richbird
The Following User Says Thank You to RICHBIRD For This Useful Post:
ROCXY (April 30th, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove orphaned html elements from html string pauliehaha C# 2008 aka C# 3.0 2 June 30th, 2008 09:40 AM
unique attribute names for form elements fishmonkey XSLT 3 March 16th, 2008 07:46 PM
XSLT - Grouping by Attribute but same elements vinaura XSLT 2 July 18th, 2007 10:34 PM
elements to attribute value samedan XSLT 0 July 4th, 2005 11:05 AM
Drag and Drop Tables Like my.msn usmanishaque Javascript 0 September 27th, 2004 06:25 AM





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