no html tags

D

David Schwartz

I'm processing some xml with xsl stylesheets and, for some reason, I
have one stylesheet that does not produce the needed html tags in the
output. I can't figure out why this stylesheet would be different from
all my others which I'm using quite successfully.

Here are the key tags I'm using:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform"
xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect" extension-
element-prefixes="redirect">
<xsl:eek:utput method="html" media-type="text/html" version="4.0"
indent="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
encoding="ISO-8859-1"/>

Here's an example of one of my templates that should be producing
html:
<xsl:template match="para">
<p><xsl:apply-templates/></p>
</xsl:template>

Can't get simpler than that, eh?

As I produce other html output just fine with other stylesheets, this
doesn't seem to be a configuration issue.

Any hints re what I should look for would be greatly appreciated!

TIA,
David
 
J

Joseph Kesselman

Is that template actually being invoked? See your XSLT processor's
trace/debugging features, and/or my developerWorks articles on styling
stylesheets so they report trace information.

You didn't give us anywhere near enough info, but my wild guesses would
be one of: you don't have a root template, or something isn't doing the
needed apply-templates to reach this point in the input document, or
your input document is namespaced.
 
J

Joseph Kesselman

Joseph said:
Is that template actually being invoked? See your XSLT processor's
trace/debugging features, and/or my developerWorks articles on styling
stylesheets so they report trace information.

Or just insert an xsl:message and see if it appears on the console.
 
D

David Schwartz

Or just insert an xsl:message and see if it appears on the console.

Sorry that I wasn't clearer in my original posting. I know that the
various templates are being accessed because the xml data are being
output; they simply aren't being bounded by the html tags that are
used in the templates. To use the 'para' template above, I get the
paragraphs but they're not surrounded by <p></p>.

I also confirmed this using <xsl:message>.

David
 
D

David Schwartz

You didn't give us anywhere near enough info, but my wild guesses would
be one of: you don't have a root template, or something isn't doing the
needed apply-templates to reach this point in the input document, or
your input document is namespaced.
What do you mean by the last statement re namespace? Are you talking
about the xml file?

David
 
J

Joseph Kesselman

What do you mean by the last statement re namespace? Are you talking
about the xml file?

Yes. The match pattern "para" will not match <para> if the element is in
the scope of a default namespace declaration, just as it won't match
<foo:para> where foo was bound to that namespace.
 
J

Joseph Kesselman

David said:
I get the paragraphs but they're not surrounded by <p></p>.

From what you've described, that shouldn't be happening unless you're
not matching the template you think you're matching, or you've set the
output mode to text, or you're doing something strange with the
processor's output, or your processor is broken.

Sorry, can't diagnose further given the minimal information you've
provided. Consider posting a 20-line stylesheet and 10-line input
document which demonstrate the problem. Simply trying to reduce the
problem to its essentials is often enough to expose the mistake; if not,
it gives us something we can look at without having to guess what else
may be going on.
 
D

David Schwartz

Sorry, can't diagnose further given the minimal information you've
provided. Consider posting a 20-line stylesheet and 10-line input
document which demonstrate the problem.

Here you go and THANKS!!!!

******************** stylesheet ********************
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
extension-element-prefixes="redirect">
<xsl:eek:utput method="html" media-type="text/html" version="4.0"
indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
encoding="ISO-8859-1"/>
<!--
======================================================================
-->
<!-- ====== This stylesheet creates a page with the html ==========
-->
<!-- =============== to be entered into pluto pages for onePlace
========== -->
<!--
======================================================================
-->

<xsl:template match="design-solutions">
<redirect:write file="pattern-html-for-1P.html">
<html lang="en-us">
<body bgcolor="#FFFFFF">
<xsl:for-each select="ui-design-patterns/ui-design-pattern">
<xsl:text> ================== </xsl:text>
PLUTO: <xsl:value-of select="@pluto-id"/>
TITLE: <xsl:value-of select="title"/>
GOAL
<xsl:apply-templates select="goal"/>
<div>
<span style="font-color:gray">Aliases:</span>
<xsl:if test="not(alias)">None</xsl:if>
<xsl:for-each select="alias">
<xsl:sort/>
<xsl:value-of select="."/>
<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
</div><xsl:text>
</xsl:text>
</xsl:for-each>
</body>
</html>
</redirect:write>
</xsl:template>

<!--
================================================================= -->
<!-- ========================== Other templates
========================= -->
<!--
================================================================= -->
<xsl:template match="goal">
<div>
<xsl:apply-templates/>
</div><xsl:text>
</xsl:text>
</xsl:template>

<xsl:template match="description">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="para">
<p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="bullet">
<li><xsl:apply-templates/></li>
</xsl:template>

<xsl:template match="bullet-para">
<p><xsl:apply-templates/></p>
</xsl:template>
</xsl:stylesheet>

******************** XML data snippet ********************
<?xml version='1.0' encoding='UTF-8'?>
<design-solutions xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" project-name="IBM Design Leadership UI Design Patterns
Initiative" last-updated="07.05.09 10:40 PST"
xsi:noNamespaceSchemaLocation="design-solution.xsd">
<ui-design-patterns>
<ui-design-pattern id="des-pat-001" version="0.0.01" pluto-
id="1011">
<title>Auto-complete</title>
<goal>
<description>
<para>The user wants to enter text into an entry field
quickly and accurately.</para>
</description>
</goal>
<use-when>
<description>
<unordered-bullets>
<bullet>
<bullet-para>The likely text value is already known and
the currently entered value can be matched to the known values.</
bullet-para>
</bullet>
<bullet>
<bullet-para>The user would benefit from or appreciate
having the system provide suggested values.</bullet-para>
</bullet>
<bullet>
<bullet-para>The possible values are either constrained
or unconstrained.</bullet-para>
</bullet>
</unordered-bullets>
</description>
</use-when>


***************** Sample of current output ********************
================= Wizard ==================
PLUTO: 1016
TITLE: Wizard
GOAL


The designer wants to simplify a complex and/or infrequent
task that is necessary for the user to acheive their goal.
The user doesn't want to have to know too much about the
application to accomplish their goal.


Aliases:None
Clients:None specified
Lifecycle phase:None specified
================= Path ==================
PLUTO: 1274
TITLE: Path
GOAL


The user wants to easily navigate to pages above the current
page in the site hierarchy.
The developer wants to orient the user regarding the
position of the current page within the site hierarchy.


Aliases:None
Clients:None specified
Lifecycle phase:None specified
 
J

Joe Kesselman

Posting a well-formed sample would have helped. Don't waste our time on
correcting pure sloppiness, please.

After fixing that... xsl:message says the para template being invoked
only once. That makes perfect sense; there is only one <para> in your
sample fragment. I can insert another, but since there odds of my
guessing where it would have to appear in order to provoke the symptom
are nil, I'm going to hand this back to you.

Post an example which DEMONSTRATES THE PROBLEM. If you want me to read
your mind, you need to pay me consulting rates.
 
J

Joe Kesselman

I forgot to say: When I ran this, the one invocation of that template
*DID* generate the <p> tags, as expected. Which is why I want to see a
complete example that fails on your system.

Standard reminder: You aren't doing something careless like trying to
use an HTML browser to look at the output, right?
 
D

David Schwartz

Posting a well-formed sample would have helped. Don't waste our time on
correcting pure sloppiness, please.

Forgive me, but I didn't realize you were looking for a data file that
you yourself could process. This was NOT a case of sloppiness; I
simply didn't fully understand what you were requesting. I certainly
appreciate your help but denigrating comments aren't helpful.

It's worth noting that a colleague of mine ran this code and got the
html tags as well. Because of this, I don't think I CAN provide you
with examples that demonstrates the problem on your system. I just
can't figure out why this one stylesheet fails on mine, in contrast to
numerous other stylesheets.

And, of course, I'm looking at the output in a text editor.
 
J

Joe Kesselman

David said:
appreciate your help but denigrating comments aren't helpful.

Sorry; some folks do need to be hit over the head to get the idea. I did
say what I wanted more politely in my previous note; repeating gets
frustrating.
It's worth noting that a colleague of mine ran this code and got the
html tags as well.

In that case, it sounds like the problem is breakage in the tools. I
don't think you said which XSLT processor you're using, but as with any
software bugs are always possible.

Obvious suggestion would be to upgrade the tools to a newer version, to
switch to a different set of tools, and/or to report the bug to the
tool's authors (again, with a small runnable sample that demonstrates
the problem, and with full information about which version you're
running) so they can replicate and diagnose the failure.
And, of course, I'm looking at the output in a text editor.

Had to ask the question, just in case. I've confused myself once or
twice by forgetting that Eclipse will automagically try to display HTML
using a browser rather than a text editor, so I assume that others are
equally fallable and it never hurts to do a sanity-check.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top