This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

not-having-attribute


From the XPath specification, I know 

para[@type = "warning"]

selects all para nodes with an attribute type = "warning." Similarly, 

para[@type]

selects all para nodes with a type attribute. Is it possible to get an
inversion of the latter? i.e. "all para nodes that do NOT contain a type
attribute OR nodes that contain a value not equal to warning?"

My source is like this (roughly):

<fields>
  <field id="foo" pkey="true"/>
  <field id="foo2/>
</fields>

I want to select all non-pkey field nodes, but this search

fields/field[@pkey != 'true']

results in an empty set because it's only taking into consideration nodes that
have a value at all. From the note at the end of XPath section 5.3
(http://www.w3.org/TR/1999/REC-xpath-19991116.html#attribute-nodes) I gather
that I need to use a validating XML parser if I want this to work at all.

Okay, so I can put in pkey = false on the input, or I need to always use a DTD
and validating parser. Fine. But is there a way to do it with a non-validating
parser for speed and to not have this (perhaps not immediately apparent)
dependency on a validating parser for my stylesheet?

regards,
kd





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]