Re: [xsl] Newbie Question: Creating Error Description from Invalid Input

Subject: Re: [xsl] Newbie Question: Creating Error Description from Invalid Input
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 13 Oct 2006 13:01:15 -0400
At 10:41 AM 10/13/2006, Richard wrote:
If there is a XPath expression to match elements by whether they have any text
content or not which would be better:


<xsl:template match="header">
  <header>
    <xsl:apply-templates select="all address* children with content" />
  </header>
  <xsl:if test="count(all address* children without content) &gt; 0">
    <errorDescription>
      <xsl:value-of select="all address* children without content" />
    </errorDescription>
  </xsl:if>
</xsl:template>

Any ideas if such an XPath exists?

select="address[normalize-space()]"


selects all address element children that have some non-whitespace text content within them.

select="address[not(normalize-space()]" selects address elements that contain only whitespace, nothing, or elements containing only whitespace, nothing (or elements containing only whitespace, nothing, etc). This is because it tests for the string value of the element, after whitespace is normalized and trimmed.

This can be changed or adjusted for other definitions of "content".

Cheers,
Wendell

Current Thread