Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I do XSLT on narrative-centric XML

    I want to turn something like this

    <heading>All your base are belong to <emphasis>us</emphasis></heading>

    into something like this

    <h1>All your base are belong to <em>us</em></h1>


    Basically - how to transform nodes which may have mixed content.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #2
    New to the CF scene
    Join Date
    Apr 2003
    Location
    Pub
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    First you should try to use a pre-defined schema, such as docbook, this way you will find a much wider range of support for it.

    Firstly is you html; xhtml compliant if so you will find it easier to replace as you can simply parse the xhtml for an xml file interchangeably and then parse that with xslt.

    as an example...


    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
        <xsl:for-each select="heading">
          <b><xsl:value-of select="." /></b>
        </xsl:for-each>
    </xsl:template>
    
    </xsl:stylesheet>
    basically it will wrap your heading element inside an bold element.

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you - but value-of won't apply the emphasis, it will just write the heading at the same weight. I'm already quite familiar with XSLT - but how to parse a node where the node contains mixed data, that's my question.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •