Re: [xsl] XPath which tests that an element does not have mixed content?

Subject: Re: [xsl] XPath which tests that an element does not have mixed content?
From: Liam R E Quin <liam@xxxxxx>
Date: Thu, 03 Nov 2011 12:01:59 -0700
On Thu, 2011-11-03 at 18:44 +0000, Costello, Roger L. wrote:
> Hi Folks,
> 
> Would you please recommend an XPath expression which ensures that the
> content of <author> is optional whitespace, <Person>, optional
> whitespace, and nothing else:

Why would you not do this with a schema (XSD, DTD, ...)?

In XPath you can of course write,
    text()[not(string-length(normalize-space(.)) = 0)][1]
to find text nodes that are not all-white, and
    count(Person) eq 1
to make sure there's exactly one Person element,
and combine the expressions (with and, or with two predicates).

Liam

-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml

Current Thread