Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Pattern problem >Thread Next - Re: Pattern problem Re: Pattern problemTo: NULL Date: 8/13/2008 9:08:00 AM "Martin Honnen" <mahotrash@y...> wrote in message news:eXhB7bU$IHA.2060@T...... > tshad wrote: > >> ancestor::form/@name gives me 1007, as it should. But I need to look at >> all the forms on the same level and get the one that has @primary = >> 'true' and use the @name of that form. >> >> Is this the wrong way to get that? >> >> Seems pretty straight forward. >> >> I assume the pattern in: >> >> <xsl:value-of select="ancestor::form[@primary='true']/@name"/> >> >> says to look for all the ancestor "form" tags and look at the one that >> one. I did notice that I had primary set in my program without the "@". >> But even after changing it to the above is not working. > > The sample XML you posted looks like this: > > <Report> > <appraisal> > <data> > <form name="1007" primary="false"> > <section type="subject" number="0"> > <tag name="GR_AGE.1" flags="1" format="4096">4 Yrs.</tag> > </section> > </form> > <form name="reffee" primary="false"> > <tag name="FFHD_NFIP_COMMUNITY_NUMBER.1" flags="0" > format="0">040040</tag> > </form> > <form name="1004_05" primary="true"> > <section type="subject" number="0"> > <tag name="PROP_PHYS_DEFICIENCIES_DESC.1" flags="4" > format="4096">None apparent </tag> > </section> > </form> > </data> > </appraisal> > </Report> > > In that sample each 'tag' element has just one ancestor element of the > name 'form'. However each such 'form' element has siblings so perhaps you > want > <xsl:value-of select="( > ancestor::form[@primary = 'true'] | > ancestor::form/preceding-sibling::form[@primary = 'true'] | > ancestor::form/following-sibling::form[@primary = 'true'] > )[1]/@name"/> > which looks at the sibling 'form' elements as well. > That worked perfectly. Just a couple of questions. Since I know that 1007 is not a primary form (as there is only one primary form), I assume I could just do: <xsl:value-of select="( ancestor::form/preceding-sibling::form[@primary = 'true'] | ancestor::form/following-sibling::form[@primary = 'true'] )[1]/@name"/> Does ancestor::form look only at the direct ancesters - which is why it didn't find the siblings of the ancestor? In ancestor::form/preceding-sibling::form, does it say: Look at the ancestor named form then look at all the siblings named form that came before it (and the reverse for following-sibling)? What does the [1] do? Is this in case it passes back more than one result? If there is only one result, do I need the [1]? Thanks, Tom > -- > > Martin Honnen --- MVP XML > http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
