You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by il...@ca.ibm.com on 2003/02/20 23:24:37 UTC

Re: Does Xalan support the "indent" attribute?

Hi,

Yes, Xalan supportt the indent attribute, but for performance reasons the
default indent amount is 0.  See this link for information on setting the
indent amount:

http://xml.apache.org/xalan-j/usagepatterns.html#outputprops

Ilene.




                                                                                                                                       
                      Fabian Gonzalez                                                                                                  
                      <fa...@yahoo.com>        To:       xalan-j-users@xml.apache.org                                                  
                                               cc:                                                                                     
                      02/20/2003 05:03         Subject:  Does Xalan support the <xsl:output> "indent" attribute?                       
                      PM                                                                                                               
                      Please respond to                                                                                                
                      fabgo                                                                                                            
                                                                                                                                       
                                                                                                                                       



I am using Xalan and Xerces to do XML transformations.
However, I cannot get Xalan to indent the XML target
document. Does Xalan support the <xsl:output
indent="yes"> attribute? If no, is there another way
to achieve indentation?

Here is the Java code I use for transformation:

File sourceFile = new File("TestSource.xml");
File stylesheetFile = new File("Test.xsl");
File targetFile = new File("TestTarget.xml");

Transformer transformer =
TransformerFactory.newInstance().newTemplates(new
StreamSource(stylesheetFile)).newTransformer();

transformer.transform(new StreamSource(sourceFile),
new StreamResult(targetFile));


The TestSource.xml document:

<?xml version="1.0" encoding="UTF-8"?>
<table name="Product">
  <column name="ProductId" primaryKey="true"
required="true" type="INTEGER"/>
  <column name="ProductName" required="true"
type="VARCHAR" size="50"/>
  <column name="ProductDesc" required="true"
type="VARCHAR" size="400"/>
  <column name="ProductPrice" required="true"
type="FLOAT"/>
</table>


And the Test.XSL stylesheet:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="table">
  <xsl:element name="table">
    <xsl:apply-templates select="column"/>
  </xsl:element>
</xsl:template>
<xsl:template match="column">
  <xsl:element name="column">
    <xsl:attribute name="name">
      <xsl:value-of select="@name"/>
    </xsl:attribute>
  </xsl:element>
</xsl:template>
</xsl:stylesheet>

Any suggestions?

- Fabian

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/