xsl-list
[Top] [All Lists]

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

2006-10-13 10:19:59
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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--