![]() |
![]() | ![]() | ![]() | 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 6:52:00 PM tshad wrote: >> <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> >> > 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"/> I have not looked in detail at your stylesheet, whether the above will do the same depends on the 'tag' element you apply it on. > Does ancestor::form look only at the direct ancesters - which is why it > didn't find the siblings of the ancestor? The ancerstor axis includes all ancestor nodes so for instance for the <tag name="GR_AGE.1" flags="1" format="4096">4 Yrs.</tag> in the sample cited above these are a 'section' element, a 'form' element, a 'data' element, an 'appraisal' element, an 'Report' element, and the document node. ancestor::form then only the selects the 'form' element nodes on the axis which in that example is a single 'form' element. > 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)? Yes. > What does the [1] do? Is this in case it passes back more than one result? It explictly selects the first of that union my sample selects. > If there is only one result, do I need the [1]? With xsl:value-of in XSLT 1.0 you do not need the [1], even if there are several elements found. I put it in because I did not know whether the XPath might find several 'form' elements and wanted to make it clear that only one should be selected for output. -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||
|
