Showing posts with label namespace. Show all posts
Showing posts with label namespace. Show all posts

2009-05-01

Getting the 'wicket:id' attribute to validate

Wicket is great. The "wicket:id" attribute is all that needs to be added to a tag to place it under program control.

If you have a finicky validator (or any validator), it may object to the attribute, which isn't part of (X)HTML.

The solution is to add a namespace declaration, like this:

<html xmlns:wicket="http://wicket.apache.org">

2008-09-03

Namespaces in XSLT

XSLT tutorials and references usually pretend that namespaces don't exist. However, when trying to process an XML document (an XHTML document in this case) that declared a namespace, none of my element node references matched!

XSLT (rightly) distinguishes between element names with no namespace qualifier (which are processed as belonging in the "no namespace" namespace) and names with an explicit qualifier, which of course are treated as belonging to that namespace.

The solution is to

  • declare a prefix for the source document's namespace(s) in the XSLT document node, like (e.g.)

    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:xhtml="http://www.w3.org/1999/xhtml">

  • use these prefixes in your patterns, like (e.g.)

    <xsl:template match="xhtml:p">



My thanks to Jeni Tennison for explaining it very clearly in this post.