[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xalan-dev
Subject:    Re: indenting
From:       Paul_Dick () lotus ! com
Date:       2000-03-13 15:07:07
[Download RAW message or body]


Chris,

XSLT is not really the tool for this.  Remember XSLT is the transform
engine of xsl.  The Formatting Objects portion of the spec is probably what
would be the better candidate for getting this type of indentation.

The indent attribute of the xsl:output statement is used for adding
additional whitespace to the output tree, not really specific elements.
That said the desired behavior can probably be achieved,  by indenting the
data with in the source .xml file.  The follow files produced what you
wanted.

XML source:
<?xml version="1.0"?>
<Book>
<Title> XSL transformations </Title>
<Summary>
   This is a block of text
   that gives a full summary
   of a book that describes
   how to use XSLT.
</Summary>
</Book>

Stylesheet:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version
="1.0">

<xsl:template match="Book">
Book_Title: <xsl:value-of select="Entry_ID"/>
Summary: <xsl:value-of select="Summary"/>
</xsl:template>

</xsl:stylesheet>

Produced:
<?xml version="1.0" encoding="UTF-8"?>

Book_Title:
Summary:
   This is a block of text
   that gives a full summary
   of a book that describes
   how to use XSLT.


Paul


                                                                                      \
                
                    Chris Gokey                                                       \
                
                    <cgokey@hydrogen.        To:     xalan-dev@xml.apache.org         \
                
                    stx.com>                 cc:     (bcc: Paul Dick/CAM/Lotus)       \
                
                    Sent by:                 Subject:     indenting                   \
                
                    cgokey@equinox.sh                                                 \
                
                    aysnet.com                                                        \
                
                                                                                      \
                
                                                                                      \
                
                    03/12/2000 06:55                                                  \
                
                    PM                                                                \
                
                    Please respond to                                                 \
                
                    xalan-dev                                                         \
                
                                                                                      \
                
                                                                                      \





Hi everyone,

I am trying to figure out how to indent text using XSLT.  Consider this
XML document:

<Book>
<Title> XSL transformations </Title>
<Summary>
This is a block of text
that gives a full summary
of a book that describes
how to use XSLT.
</Summary>
</Book>

Consider this XSL file:

?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="Book">
Book_Title: <xsl:value-of select="Entry_ID"/>
Summary:
<xsl:value-of select="Summary"/>
</xsl:template>
</xsl:stylesheet>

Now, the output looks like this:

Book_Title: XSL Transformations
Summary:
This is a block of text
that gives a full summary
of a book that describes
how to use XSLT.

And this is what I'd like:

Book_Title: XSL Transformations
Summary:
   This is a block of text
   that gives a full summary
   of a book that describes
   how to use XSLT.

How can I tell my style sheet to indent each line?

Thanks,
Chris

--
Christopher D. Gokey, Raytheon ITSS, NASA/GCMD
18 Martin Road, Shelburne Falls, MA  01370
Phone: Voice (413) 625-8129 / FAX 208-248-9055
cgokey@gcmd.nasa.gov / http://gcmd.nasa.gov


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic