Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Pattern problem

From: Martin Honnen <mahotrash@-----.-->
To: 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/


transparent
Print
Mail
Digg
delicious
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.

.
.

transparent

transparent