What advantages do you get from forcing templates to be XHTML vs. HTML?

David Magerl's Avatar

David Magerl

10 Jan, 2012 03:09 PM

It seems to me like forcing all templates to validate as XML causes a slew of unnecessary problems, to seemingly no advantage. Why not just validate that the system-region tags are well formed and not validate anything else. If the system would allow a format to be applied directly to the template xhtml (not the system-regions), then it would make sense to force xhtml, but since it doesn't, I can't see much reason for it other than it makes it easier for cascade to find the system-region tags. Maybe there are other reasons. If there are please share.

  1. 1 Posted by Joel on 10 Jan, 2012 03:51 PM

    Joel's Avatar

    Hi David,

    Cascade Server is a XML centric CMS application, thus XHTML is the supported variant of HTML. Further, XHTML proposes many benefits related to compliance, maintenance, and XSL compatibility as discussed within this article.

    If the system would allow a format to be applied directly to the template xhtml (not the system-regions), then it would make sense to force xhtml

    Could you elaborate on this perhaps? You can apply formats to page-level regions, but I may be missing your argument entirely. If so just let me know and I'll do my best to explain how this functionality behaves within Cascade Server.

    Thanks!

  2. 2 Posted by David Magerl on 10 Jan, 2012 04:25 PM

    David Magerl's Avatar

    "Cascade Server is a XML centric CMS application, thus XHTML is the
    supported variant of HTML. Further, XHTML proposes many benefits related
    to compliance, maintenance, and XSL compatibility [as discussed within this
    article.](http://www.webstandards.org/learn/articles/askw3c/oct2003/) "

    Thanks for the quick response. I want to start by saying that I really like
    Cascade. It is really flexible and better than many other CMSs that I've
    used.
    I understand that Cascade is XML centric. I also feel that in the case of
    templates that validating using XHTML is not necessary.
    As far as compliance, an HTML document can be just as compliant when
    validated against an HTML validator. It would be nice to have the option to
    validate against HTML5 or HTML4, or ignore validation completely, instead
    of always XTHML strict.
    Maintenance is subjective I suppose. I find maintaining documents when I
    don't have to worry about wrapping things in CDATA or watching out for
    special characters easier to maintain.
    XSL compatiblity is great, and it's where I was going with my comment:
        "If the system would allow a format to be applied directly to the
    template xhtml (not the system-regions), then it would make sense to force
    xhtml"
    What I am trying to say here is that Cascade only allows you to apply
    formats to system-regions, not to the template as a whole. So in my mind it
    there is no benefit to making the whole template XML, only the data that is
    put into the system-regions really needs to be XML, because it is meant to
    have a format applied to it.

    This is just something that has been bugging me for awhile, and I wanted to
    get Hannon Hill's take on it. Thanks for having the conversation with me.

  3. 3 Posted by Joel on 10 Jan, 2012 04:31 PM

    Joel's Avatar

    David,

    Those are all very good points! As for applying the XSL to the entire page so to say, this is actually possible. If you edit a Template, click on the Regions pane, the first field you see there is for a XSLT format. That format will be applied to the entire Page, and thus Template. You can do this at the Configuration level as well as the Page level.

    Thanks!

  4. 4 Posted by David Magerl on 10 Jan, 2012 04:34 PM

    David Magerl's Avatar

    I was under the impression that a format applied in the way you described
    would only apply to the default system-region, not to the template itself.
    Is that not correct?

  5. Support Staff 5 Posted by Tim on 10 Jan, 2012 04:42 PM

    Tim's Avatar

    Hi David,

    A Format applied at the Template, Configuration, or Page level (as Joel mentioned above) will transform the fully rendered Page (which includes the portions of code from the Template). This should not be confused with applying Formats at the region level.

    To apply a Format to the fully rendered Page at the Template level:
    Edit the Template, click the Regions pane. The first field allows you to choose an XSLT Format.

    To do this at the Configuration level:
    Edit a Configuration Set, click on a Configuration, then look for the XSLT Format field (third field down from the top).

    To do this at the Page level:
    Edit a Page, click the Configurations pane, find the XSLT Format field at the top (second field down from the top).

    With these types of Formats you will be matching on the root element from your Template (<html>) as opposed to something like <system-index-block> or <system-data-structure> (which you would normally match on when attaching a Format to a particular region on the page).

    Hope this makes sense!

  6. 6 Posted by David Magerl on 10 Jan, 2012 04:48 PM

    David Magerl's Avatar

    Yeah, that makes perfect sense, in fact that's how I always assumed it
    worked, but I was recently told otherwise. I'll have to give this a try.
    Thanks.

  7. Support Staff 7 Posted by Tim on 10 Jan, 2012 04:55 PM

    Tim's Avatar

    Cool! Let us know if you run into any problems.

  8. 8 Posted by David Magerl on 10 Jan, 2012 07:03 PM

    David Magerl's Avatar

    When you apply a format to the template do you have to match on the root
    element (html), or is it possible to apply a transformation just on a child
    node. It was trying this and whenever I try not matching on / or html I get
    an error message. Just wondering if I'm doing it wrong or if it's not
    possible.

  9. Support Staff 9 Posted by Tim on 10 Jan, 2012 07:29 PM

    Tim's Avatar

    Can you attach a file containing the fully rendered page source code along with the Format you are attempting to use to transform it? I'll be happy to take a look to see if I can provide some recommendations.

  10. 10 Posted by David Magerl on 10 Jan, 2012 07:53 PM

    David Magerl's Avatar

    On Tue, Jan 10, 2012 at 2:29 PM, Tim <
    [email blocked]> wrote:

    >
    > // Add your reply above here
    > ==================================================
    > From: Tim
    > Subject: What advantages do you get from forcing templates to be XHTML vs.
    > HTML?
    >
    > Can you attach a file containing the fully rendered page source code along
    > with the Format you are attempting to use to transform it? I'll be happy
    > to take a look to see if I can provide some recommendations.
    >
    >
    > View this Discussion online:
    > http://help.hannonhill.com/discussions/general/467-what-advantages-do-you-get-from-forcing-templates-to-be-xhtml-vs-html
    > --
    >
    > Reply with #ignore to stop receiving notifications for this discussion.
    >
    >

    NOTE: The information contained
    in this e-mail message, including
    any attachments, may be privileged
    or confidential. Use or dissemination
    of this message is prohibited by
    anyone other than the intended
    recipient. Although our computer
    system is supposed to scan incoming
    e-mail and any attachments for viruses
    or other defects that might harm
    computer systems, BARKLEY disclaims
    any responsibility for any resulting loss

  11. Support Staff 11 Posted by Tim on 10 Jan, 2012 09:22 PM

    Tim's Avatar

    Give something like this a try for your XSLT:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
        <xsl:template match="html">
            <xsl:apply-templates select="body"/>
        </xsl:template>
        <xsl:template match="body">
           <div>this div will be inside of the body tag</div>
        </xsl:template>
    </xsl:stylesheet>
    
  12. 12 Posted by David Magerl on 10 Jan, 2012 09:32 PM

    David Magerl's Avatar

    Thank you for your reply. The code you gave me does work, but it does not
    answer my question.

       <?xml version="1.0" encoding="UTF-8"?>
       <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
           <xsl:template match="html"> "I know that matching on html or / will
    work. I was asking if it is possible to not match on either of these and
    rather match on a child such as
                                                       body or header or
    basically any valid xpath."
               <xsl:apply-templates select="body"/>
           </xsl:template>
           <xsl:template match="body">
              <div>this div will be inside of the body tag</div>
           </xsl:template>
       </xsl:stylesheet>

  13. 13 Posted by David Magerl on 10 Jan, 2012 09:35 PM

    David Magerl's Avatar

    Also, <div>this div will be inside of the body tag</div> does not render
    inside of the body tag in your example, it is the only thing that gets
    rendered on the page.

  14. Support Staff 14 Posted by Tim on 10 Jan, 2012 09:46 PM

    Tim's Avatar

    I know that matching on html or / will work. I was asking if it is possible to not match on either of these and rather match on a child such as body or header or basically any valid xpath.

    From my experience with the XSLT processor in Cascade (Xalan), you always need to match the root element before doing anything else. If you don't, you'll generally see a bunch of garbage output in your page (from the nodes it is skipping in the XML tree). My suggestion is to match the <html> tag first and then use the <xsl:apply-templates> function to match the child element you are looking for.

    Also,

    this div will be inside of the body tag
    does not render inside of the body tag in your example, it is the only thing that gets
    rendered on the page.

    Sorry, I meant that the output should appear like this:

    ...
    <body>
        <div> ... </div>
    </body>
    ....
    

    Is there something specific you are attempting to do with the fully rendered page? I'll be glad to give you a better example if you can provide more details.

    Just let me know.

  15. 15 Posted by David Magerl on 10 Jan, 2012 10:01 PM

    David Magerl's Avatar

    When applying XSLT to a system-region it makes sense to match on the root
    element because what you don't match would be garbage xml that you don't
    want to render to the page. In this case, applying XSLT to a template,
    matching on a child and not the root would be a good way to change just
    pieces of the page, and the left over content in this case would not be
    garbage xml, but rather useful XHTML from the rest of the template.
    Matching on the root would force you to rebuild the entire page in your
    format, making the ability to apply a format to a template pretty darn
    useless.

    I'm not trying to do anything in specific, just wondering the limitations
    of Cascade. Obviously, there are other (if slightly less elegant) ways to
    do what I'm after.

        Sorry, I meant that the output should appear like this:
           ...
           <body>
               <div> ... </div>
           </body>

    This is not the output you get from your example. The body tag is not
    rendered, only the div.

  16. Support Staff 16 Posted by Tim on 11 Jan, 2012 01:49 PM

    Tim's Avatar

    I agree - however, this isn't too difficult to do using XSLT. Check out this old discussion where I wrote a pretty simple XSLT Format which will do exactly as you mention (rebuild the page). You should be able to use similar logic for other use cases as well.

    This is not the output you get from your example. The body tag is not rendered, only the div.

    Yep! You're right. Sorry - in the example I set up, I was taking your entire HTML document and creating a new XML Block with it. Then, I was applying a Format to that Block in a region (so that I didn't have to recreate your Template). So, when I viewed the source it still contained the <body> tags since that was a part of my Template that was already set up. The example I posted above should hopefully help you out to where you can have your Page essentially rebuilt along with whatever modifications to specific elements you may decide to make.

  17. Tim closed this discussion on 09 Feb, 2012 01:11 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac