Re: [xsl] Counting nodes - now specifying body in stylesheet

Subject: Re: [xsl] Counting nodes - now specifying body in stylesheet
From: "Mike Leahy" <mgleahy@xxxxxxxxxxxxxxxx>
Date: Tue, 2 Jul 2002 15:38:50 -0400
My apologies, after testing the first example again, the xsl commands do
work - however when I use the sample code below (which is more like the
actual code I'm using), my table ends up being a mile wide once I add the
body element.  All the information is there, but it is appearing off-screen
(I never noticed this before).  This doesn't happen without the body
element.  I removed the "width" attribute from the tables, and that
eliminated the problem, but now my tables are too small.  I guess the
percentage is not recognized properly.

Last, when I specify the body attributes (e.g. using a background image or
color), the body only applies to the immediate area around the text/tables,
not the entire document.  So the result is a small area with a background,
and whitespace for the rest of the page.  Is there a solution for that?

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="";
<xsl:template match="/">
<body bgcolor="#bbbbbb">
<TABLE cellpadding="2" width="96%" bordercolor="#000000" cellspacing="2">
    <xsl:for-each select="metadata/idinfo/citation/citeinfo/onlink">
    <B><font face="Arial"><a><xsl:attribute name="href"><xsl:value-of
select="."/></xsl:attribute>View Map</a></font></B>
    <xsl:if test="(position() != last())"><br/>
    <TD COLSPAN="2" BORDER="2" align="right"><font color="#00000"
face="Arial, Helvetica, sans-serif" size="3"><B><xsl:value-of
select="metadata/idinfo/citation/citeinfo/title"/> - <xsl:value-of
<TABLE width="100%" BORDER="2" cellpadding="2" bordercolor="#000000">
    <TD HEIGHT="30" VALIGN="bottom" bgcolor="#FFFFFF" bordercolor="#000000"
cellpadding="2"> <font face="Arial, Helvetica, sans-serif" size="2"><A
    <TD COLSPAN="2" align="center"><font color="#000000" face="Arial,
Helvetica, sans-serif" size="2"><B>IDENTIFICATION
    <TD ROWSPAN="4"><font face="Arial, Helvetica, sans-serif" size="2"><a
    <TD COLSPAN="2" align="center" bgcolor="#cccccc"><font color="#000000"
face="Arial, Helvetica, sans-serif" size="2"><b>Citation</b></font></TD>
    <TD bgcolor="#f5f5f5"><font face="Arial, Helvetica, sans-serif"
size="2"><b><font color="#000000">Originator</font></b></font></TD>
    <TD bgcolor="#f5f5f5"><font color="#000000" face="Arial, Helvetica,
sans-serif" size="2"><xsl:value-of

I'm viewing the XML document through Netscape 6.02 - I don't know what
processor it is using.  How can I find out?

Here is a sample of what my XML code would look like:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?>
<metadata xml:lang="en">
         <onlink>Online Link URL 1</onlink>
         <onlink>Online Link URL 2 (and so on)</onlink>
         <origin>Originiator name</origin>

Thanks for your help,

----- Original Message -----
From: "Wendell Piez" <wapiez@xxxxxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, July 02, 2002 11:49 AM
Subject: Re: [xsl] Counting nodes - now specifying body in stylesheet

> Mike,
> Definitely switch to XSLT. The sooner you switch, the more grief you'll
> save yourself.
> At 11:12 AM 7/2/2002, you wrote:
> >Regarding the namespace I am using, one of the reasons I have not moved
> >the newer namespace is that I cannot seem to make an output stylesheet
> >very nice using the namespace.
> >
> >Perhaps, someone could give me suggestions with this problem:
> >
> >The biggest issue I have is when I try to define the body of the
> >In the example below, I have a couple simple xsl commands, and I've
> >a body with a background color.
> >
> >Normally, I would get a list of all the
> >"metadata/idinfo/citation/citeinfo/onlink" elements, followed by the
> >"metadata/idinfo/citation/citeinfo/origin" element.  However, once I have
> >entered the "<body>" tag, every xsl command following the for-each
> >end up blank - the "metadata/idinfo/citation/citeinfo/origin" will not
> >appear in the result, and I get no processing errors.  If the "<body>"
> >and it's closing tag "</body>" are removed from the code below, then
> >everything works fine, but I'm stuck with unformatted results.
> Honestly, this is baffling. Please test very carefully (using the same
> XPath expressions in your for-each select) to confirm that it's the
> presence or absence of the <body> node that makes the difference. There's
> no way in XSLT it should; it does not change the context for the
> of any expressions.
> Which processor are you using?
> >I've tried looking at formatting objects in XSL, but haven't been able to
> >get anything to work yet.
> If you're targetting web display, write XSLT that creates HTML (for now).
> At present FOs are still being used mainly to generate print output (e.g.
> in PDF).
> ><?xml version="1.0"?>
> ><xsl:stylesheet xmlns:xsl="";
> >version="1.0">
> ><xsl:template match="/">
> ><HTML>
> ><body bgcolor="#cccccc">
> >
> ><xsl:for-each select="metadata/idinfo/citation/citeinfo/onlink">
> If you're not getting your values reported, it's probably because this
> XPath returns no nodes. Does your source look more or less like
> <?xml version="1.0"?>
> <DEFANGED_metadata>
>    <idinfo>
>      <citation>
>        <citeinfo>
>          <onlink>Here's the value you want</onlink>
>        </citeinfo>
>      </citation>
>    </idinfo>
> </metadata>
> <DEFANGED_metadata> being your document ("root") element? If not, your
XPath won't
> work. (If you post a snippet of your source, it's easy enough to see what
> XPath you need.)
> >     <xsl:value-of select="." />
> >     <xsl:if test="current()[(position() != last())]">
> This should be (position() != last())
> The test as given is never true (since the position of a node is always
> last when it's the only node selected).
> >         <br/>
> >     </xsl:if>
> ></xsl:for-each>
> >
> ><xsl:value-of select="metadata/idinfo/citation/citeinfo/origin"/>
> >
> ></body>
> ></HTML>
> ></xsl:template>
> ></xsl:stylesheet>
>  From the design of this stylesheet, it also looks like you might want to
> do a bit of homework on templates. You don't really need them for this
> simple application, but you will.
> Cheers,
> Wendell
> ======================================================================
> Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
> Mulberry Technologies, Inc.      
> 17 West Jefferson Street                    Direct Phone: 301/315-9635
> Suite 207                                          Phone: 301/315-9631
> Rockville, MD  20850                                 Fax: 301/315-8285
> ----------------------------------------------------------------------
>    Mulberry Technologies: A Consultancy Specializing in SGML and XML
> ======================================================================
>  XSL-List info and archive:

 XSL-List info and archive:

Current Thread