[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] How to test on more than one axis
Subject: Re: [xsl] How to test on more than one axis From: tcn@xxxxxxxxxxxxx (Trevor Nash) Date: Mon, 03 Sep 2001 17:40:56 GMT |
> >My XML document has a number of 'mandatory' elements, identified as such by >an attribute, for example: > > <Person> > <FirstName>David</FirstName> > <LastName Mandatory="True">Baldwin<LastName> > </Person> > >I want to be able to tell if the document is valid in the sense that all of >the 'mandatory' elements in the document contain a value. > >I have tried various approaches with count() and using a variable, for >example: > ><xsl:template match="/"> > <xsl:variable name="Invalid" select="//@Mandatory='True' and //.=''" /> > > ...more xsl using value of Invalid... > ></xsl:template> Did you try: //*[@Mandatory='True' and .=''] (all the elements which have mandatory='True' and contain no text) ? > >snip > >Is this a syntax issue, or am I trying to do something the wrong way in xsl? >At the end of the day I am just trying to check the xml contains the >required elements, and I have control of the xml schema, so maybe there is a >better way of approaching this. Any ideas? > Assuming that *all* instances of LastName are mandatory, or at least all within some specific context, then this information doesn't belong in the document: maybe you should use a DTD or a schema. If you want to stick to just using XSLT, then schematron might be worth a look. >Thanks > >David O Baldwin > Regards, Trevor Nash -- Traditional training & distance learning, Consultancy by email Melvaig Software Engineering Limited voice: +44 (0) 1445 771 271 email: tcn@xxxxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to test on more than , Aleksei Valikov | Thread | [xsl] checking checkboxes based on , Adam Darwin |
Re: [xsl] How to test on more than , Aleksei Valikov | Date | [xsl] seamless processing of multip, Dan Diebolt |
Month |
Keywords