xsl-list
[Top] [All Lists]

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

2011-11-03 16:18:54
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


--~------------------------------------------------------------------
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>
--~--