Transforming xhtml with xslt

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

  1. Puzzled

    Puzzled Guest

    http://www.biglist.com/lists/xsl-list/archives/200303/msg01242.html 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"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

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

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

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

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

    </xsl:stylesheet>
     
    Puzzled, May 28, 2007
    #1
    1. Advertising

  2. Puzzled

    roy axenov Guest

    Puzzled wrote:
    > Can some one explain what I'm doing wrong?


    Pretty much everything, I daresay. First of all, 'learning
    by tinkering' does not imply *random* tinkering.

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


    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.

    > <xsl:template match="navbar">
    > <xsl:copy>
    > <p>
    > <xsl:call-template name="topNavigation" />


    Pardon me? I don't see any named templates in your
    stylesheet.

    > </p>
    > <xsl:apply-templates select="node() != 'navbar'"/>


    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

    If only we smelled each other's asses, there wouldn't be any
    war.--Dustin Hoffman
     
    roy axenov, May 29, 2007
    #2
    1. Advertising

  3. Puzzled

    Puzzled Guest

    "Lord Snooty (roy axenov)" <> wrote in message
    news:f3fe3n$3u3$...
    >

    <snip>

    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
    #3
  4. Puzzled wrote:
    > sources to which I have access seem to be virtually worthless


    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:

    http://www.ibm.com/xml
    Many tutorials/articles/tools, courtesy of Big Blue.
    (Though not necessarily reflecting the official
    opinions of IBM.)

    http://xml.com/
    A good place to look for meta-standard such
    as commonly used schemas. Also hosts the Annotated
    XML Spec, http://www.xml.com/axml/testaxml.htm

    http://www.w3.org/
    The Official Word on most things XML

    http://www.saxproject.org/
    The Official Word on SAX (which is not W3C-developed)

    http://www.mulberrytech.com/xsl/xsl-list/
    The original unofficial XSL users' mailing list.

    http://www.dpawson.co.uk/xsl/
    The XSL FAQ; "Condensed Cream of XSL-List"

    http://xml.apache.org/
    All things XML available from (or under development at)
    Apache, including the dedicated mailing lists and
    bug reporting/tracking systems for those tools.

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
     
    Joseph Kesselman, May 29, 2007
    #4
  5. Joseph Kesselman, May 29, 2007
    #5
  6. Puzzled

    roy axenov Guest

    Puzzled wrote:
    > "Lord Snooty (roy axenov)" <> wrote in


    Oh, nice. Keep it up.

    > message news:f3fe3n$3u3$...


    > Actually, I have done an enormous amount of reading.


    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?'

    > Unfortunately, the sources to which I have access seem to
    > be virtually worthless; badly written, misleading and
    > sometimes just plain wrong.


    GIYF.

    > However, at least those authors don't seek to ridicule
    > other people for knowing less than they do


    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,
    though.

    HTH, HAND.

    *plonk*

    --
    roy axenov

    If only we smelled each other's asses, there wouldn't be any
    war.--Dustin Hoffman
     
    roy axenov, May 29, 2007
    #6
  7. Puzzled wrote:
    > 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


    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:

    http://www.catb.org/~esr/faqs/smart-questions.html

    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:
    http://www.lovesong.com/people/keshlam/filk/ravin.html

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
     
    Joe Kesselman, May 30, 2007
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Adams
    Replies:
    1
    Views:
    721
    Arnaud Berger
    Mar 10, 2005
  2. Bernd Fuhrmann
    Replies:
    0
    Views:
    446
    Bernd Fuhrmann
    Feb 12, 2004
  3. Jody Greening
    Replies:
    5
    Views:
    685
    Jody Greening
    Jan 6, 2005
  4. Usha2009
    Replies:
    0
    Views:
    1,147
    Usha2009
    Dec 20, 2009
  5. Andy
    Replies:
    9
    Views:
    2,232
    Peter Flynn
    Feb 3, 2011
Loading...

Share This Page