Transforming xhtml with xslt

Discussion in 'XML' started by Puzzled, May 28, 2007.

  1. Puzzled

    Puzzled Guest purports
    to show how xslt can be used to copy all of an xhtml file & selectively
    transform certain nodes. The copy works fine on its own, buit when I try to
    follow the example and add another template to replace <navbar> with some
    text stored in Navigation.htm, it seems to have no effect. Can some one
    explain what I'm doing wrong? My XSLT stylesheets is included below.

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0"

    <xsl:include href="Navigation.htm" />

    <xsl:eek:utput method="xml" indent="no"/>

    <xsl:template match="@*|node()">
    <xsl:apply-templates select="@*|node()"/>

    <xsl:template match="navbar">
    <xsl:call-template name="topNavigation" />
    <xsl:apply-templates select="node() != 'navbar'"/>

    Puzzled, May 28, 2007
    1. Advertisements

  2. Puzzled

    roy axenov Guest

    Pretty much everything, I daresay. First of all, 'learning
    by tinkering' does not imply *random* tinkering.
    I doubt it does what you expect it to do. In fact, I'm
    pretty certain of that, since I don't see document('')
    anywhere in your stylesheet. At least I hope your .htm file
    is well-formed XML.
    Pardon me? I don't see any named templates in your
    I doubt it does what you expect it to do (in more than one
    way, too).

    Since you failed to provide minimal complete example, it's
    hard to tell precisely what you're doing wrong, but this
    short snippet seems to demonstrate that at the very least
    you need to do some reading first. Canned solutions work
    just fine as long as you don't try to spice them up.
    roy axenov, May 29, 2007
    1. Advertisements

  3. Puzzled

    Puzzled Guest


    Actually, I have done an enormous amount of reading. Unfortunately, the
    sources to which I have access seem to be virtually worthless; badly
    written, misleading and sometimes just plain wrong. However, at least those
    authors don't seek to ridicule other people for knowing less than they do
    Puzzled, May 29, 2007
  4. Pointers to the XML educational resources I use most often; order is not
    particularly significant since which is best depends on what you're
    looking for:
    Many tutorials/articles/tools, courtesy of Big Blue.
    (Though not necessarily reflecting the official
    opinions of IBM.)
    A good place to look for meta-standard such
    as commonly used schemas. Also hosts the Annotated
    XML Spec,
    The Official Word on most things XML
    The Official Word on SAX (which is not W3C-developed)
    The original unofficial XSL users' mailing list.
    The XSL FAQ; "Condensed Cream of XSL-List"
    All things XML available from (or under development at)
    Apache, including the dedicated mailing lists and
    bug reporting/tracking systems for those tools.
    Joseph Kesselman, May 29, 2007
  5. Joseph Kesselman, May 29, 2007
  6. Puzzled

    roy axenov Guest

    Oh, nice. Keep it up.
    I'm afraid there's something wrong with your reading
    comprehension then. Either that, or you've been reading
    mystery novels. Otherwise you wouldn't have asked a
    question that is largely equivalent to 'I need to find gcd
    of two numbers--32 and 48. Unfortunately, adding them and
    looking at page 80 in volume 2 of Encyclopaedia Britannica
    doesn't seem to work. What am I doing wrong?'
    Not knowing something is not ridiculous in the least.
    Failing to do even most basic research (such as looking up
    node() in any XPath reference and xsl:include in any XSLT
    reference) and asking nonsensical questions certainly is,

    HTH, HAND.

    roy axenov, May 29, 2007
  7. A somewhat "snooty" but VERY good document on how to pose questions in a
    way that's most likely to get useful answers from other newsgroup readers:

    I'll also remind folks that the same document has a section on writing
    good answers. Generally, the simplest way to deal with a bad question is
    either to ignore it, to point them at that document, or to point them at
    the websearch they should have issued. Sniping generally just makes them
    defensive, and they don't learn when they're being defensive.

    Somewhat related to that, though it's about off-topic posts rather than
    poorly structured questions:
    Joe Kesselman, May 30, 2007
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.