GeeCON Prague 2014*
The moose likes XML and Related Technologies and the fly likes Code Allignment In Xml Spy Editor 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 "Code Allignment In Xml Spy Editor" Watch "Code Allignment In Xml Spy Editor" New topic
Author

Code Allignment In Xml Spy Editor

Rajitha Ereddy
Greenhorn

Joined: Nov 26, 2000
Posts: 20
Hi,
Is there any option in XML SPY Editor,So that i can allign my code properly.Please help me out in solving this problem.
Thanks
Rajitha
shantanu sharma
Greenhorn

Joined: Jan 25, 2001
Posts: 5
Hi Rajitha,
As such there is no option that aligns the code but there is a way. Write or copy/paste the code in the editor window. Now to align the code, click on the "Enhanced Grid View" button and then click back on the "Text View" button. This should align the code automatically.
Shantanu
Rajitha Ereddy
Greenhorn

Joined: Nov 26, 2000
Posts: 20
Hi Shantanu,
Thanks a lot and it is working perfectly and so easy way and i have one more doubt in XSL if u can.Its like i have a table called transaction and the XML for that perticular table is as given:
<Transaction>
<TransactionDate>10/02/1999</TransactionDate>
<TransactionDescription>Interest paid</TransactionDescription>
<Sequence>Transaction Sequence Number</Sequence>
<Amount>50.00</Amount>
<Balance>2000.00</Balance>
</Transaction>

so for this table i want the xsl insuch a way that the alternate rows bgcolors should be diff like if even No: rows are blue in color i want the odd No: rows to be in yellow color so iam doing it using the position method but it is not working and my XSL goes like this:

<xsl:template match="Transaction">
<xsl:variable name="var">
<xsl:choose>
<xsl:when test=" position( ) mod 2 = 0">bgcolor=#FF6600</xsl:when>
<xsl therwise>bgcolor=#FFFFFF</xsl therwise>
</xsl:choose>
</xsl:variable>
<tr valign="top">
<xsl:attribute name="bgcolor"><xsl:value-of select="$var"/></xsl:attribute>
<td width="23%" align="center">
<xsl:value-of select="TransactionDate"/>
</td>
<td width="23%" align="center">
<xsl:value-of select="TransactionDescription"/>
</td>
<td width="23%" align="center">
<xsl:value-of select="Amount"/>
</td>
<td width="23%" align="center">
<xsl:value-of select="Balance"/>
</td>
<td width="40%">
<table border="0" cellspacing="1" cellpadding="1" width="677">
<tr>
<td width="103" height="21" bgcolor="#FFFFFF">
<xsl:value-of select="TransactionDate"/>
<font size="2" face="arial" color="#003366">
<xsl:value-of select="TransactionDate"/>
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
</font>
</td>
<td width="322" height="21" bgcolor="#FFFFFF">
<font size="2" face="arial" color="#003366">
<xsl:value-of select="TransactionDescription"/>
</font>
</td>
<td width="98" height="21" bgcolor="#FFFFFF">
<font size="2" face="arial" color="#003366">
<xsl:value-of select="Amount"/>
</font>
</td>
<td width="101" height="21" bgcolor="#FFFFFF">
<font size="2" face="arial" color="#003366">
<xsl:value-of select="Balance"/>
</font>
</td>
</tr>
<!--</xsl:for-each>-->
</table>
</td>
</tr>
</xsl:template>

So if possible can anyone tell how it can be achieved and i will be very thankful for that.Anyway thanks in advance.
Regards,
Rajitha.
shantanu sharma
Greenhorn

Joined: Jan 25, 2001
Posts: 5
Hi Rajitha,
Sorry I took long time to reply..
Here is an XML that is working...the XSL is also there
This XSL paints alternate rows with defined colors..
-----------
XML
-----------
<?xml version="1.0" encoding="UTF-8"?>
<Transactions>
<Transaction>
<TransactionDate>10/02/1999</TransactionDate>
<TransactionDescription>Interest paid</TransactionDescription>
<Sequence>Transaction Sequence Number</Sequence>
<Amount>50.00</Amount>
<Balance>2000.00</Balance>
</Transaction>
<Transaction>
<TransactionDate>10/02/1999</TransactionDate>
<TransactionDescription>Interest paid</TransactionDescription>
<Sequence>Transaction Sequence Number</Sequence>
<Amount>50.00</Amount>
<Balance>2000.00</Balance>
</Transaction>
<Transaction>
<TransactionDate>10/02/1999</TransactionDate>
<TransactionDescription>Interest paid</TransactionDescription>
<Sequence>Transaction Sequence Number</Sequence>
<Amount>50.00</Amount>
<Balance>2000.00</Balance>
</Transaction>
<Transaction>
<TransactionDate>10/02/1999</TransactionDate>
<TransactionDescription>Interest paid</TransactionDescription>
<Sequence>Transaction Sequence Number</Sequence>
<Amount>50.00</Amount>
<Balance>2000.00</Balance>
</Transaction>
</Transactions>
--------------
XSL
--------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Transactions">
<html>
<body>
<table>
<xsl:for-each select="./Transaction">
<tr>
<xsl:choose>
<xsl:when test="position() mod 2 = 0">
<xsl:attribute name="bgcolor">blue</xsl:attribute>
</xsl:when>
<xsltherwise>
<xsl:attribute name="bgcolor">yellow</xsl:attribute>
</xsltherwise>
</xsl:choose>
<xsl:for-each select="./*">
<td>
<xsl:value-of select="."/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
This XML prints the desired output.
Shantanu.
Rajitha Ereddy
Greenhorn

Joined: Nov 26, 2000
Posts: 20
Hi Shantanu,
Thanks for the reply and i shall try it out.
Regards,
Rajitha.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Code Allignment In Xml Spy Editor