[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XPath which tests that an element does not have

Subject: Re: XPath which tests that an element does not have mixed content?
From: Hermann Stamm-Wilbrandt <STAMMW@xxxxxxxxxx>
Date: Thu, 3 Nov 2011 20:02:12 +0100
Re:  XPath which tests that an element does not have
With xpath++ based on xsltproc and EXSLT this can be done similar:

$ xpath++ "normalize-space(str:concat((//author|//person)/text()))!=''"
author.xml
true
$


Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Level 3 support for XML Compiler team, Fixpack team lead
WebSphere DataPower SOA Appliances
https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


                                                                                                                   
  From:       "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>                                                      
                                                                                                                   
  To:         xsl-list@xxxxxxxxxxxxxxxxxxxxxx,                                                                     
                                                                                                                   
  Date:       11/03/2011 07:53 PM                                                                                  
                                                                                                                   
  Subject:    Re:  XPath which tests that an element does not have  mixed content?                            
                                                                                                                   





At 2011-11-03 18:44 +0000, Costello, Roger L. wrote:
>Would you please recommend an XPath expression which ensures that
>the content of <author> is optional whitespace, <Person>, optional
>whitespace, and nothing else:
>
>     <author>
>         <Person>
>             <name>Simon L. Peyton Jones</name>
>         </Person>
>     </author>
>
>The result of the XPath expression is true if the content is as
>desired and false otherwise. The XPath should return true for the
>above example and false for the below example:
>
>     <author>
>        The person is:
>         <Person>
>             <name>Simon L. Peyton Jones</name>
>         </Person>
>     </author>

In XSLT 2.0 you could test the join of text() children of the cited
elements along the lines of:

   not(normalize-space( string-join( (author,Person)/text() ),'')))

I hope this helps.

. . . . . . . . . . Ken




--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.