Altova Mailing List Archives


Re: easy question - empty element?

From: Pavel Lepin <p.lepin@-------.--->
To: NULL
Date: 10/30/2007 4:25:00 PM


Andy Dingley <dingbat@c...> wrote in
<1193746661.437370.311060@k...>:
> On 30 Oct, 08:53, Pavel Lepin <p.le...@ctncorp.com> wrote:
>> Depending on what you mean by 'empty', you might actually
>> want one of the following:
>>
>>   //*[@boId and not(descendant::text())]
>>   //*[@boId and not(node())]
>>   //*[@boId and not(text()[normalize-space()])]
>>   //*[@boId and
>>   not(descendant::text()[normalize-space()])]
> 
> I can't imagine many situations where "//*[...]" is a good
> idea, especially not for an XPath newbie.

There certainly are some. Processing meta-data stored in
attributes from a dedicated namespace seems to be one of
the more common use cases.

> That's going to match every element in the tree, depending
> only on a complex predicate to filter them.

Them's the breaks.

> As you usually know the element name you're trying to
> match...

Usually, but not necessarily.

> I'd also strongly recommend a more readable element named
> "<policy>" rather than "<Plcy>".

Agreed in principle, but in this case it took me all of a
quarter a second to parse 'Plcy'.

-- 
It is rare to find learned men who are clean, do not stink,
and have a sense of humour. -- Liselotte in a letter to
Sophie, 30 Jul 1705

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.