[xsl] Finding referenced / refered element in any level within a common parent element

Subject: [xsl] Finding referenced / refered element in any level within a common parent element
From: Karl <call14@xxxxxxxxx>
Date: Tue, 10 Oct 2006 10:53:47 +0100 (BST)
We have a xml where we convert each <SubSection> into a seperate html
page. Use xslt 1 only. In the content, we have reference to images
like <a type="figure" href="FIG007_001">Figure 1</a> and then actual
image is described within a <Figure id="FIG007_001"> elememt in any
<Subsectioin>. Pls see the xml below

We are supposed to link the <a href/> to the correct image in
whichevr page the <Figure id="FIG007_00Y"/> is described. But due to
other technical issues, we failed on that part and hence we now want
to

1) Make a href link if the referenced figure appear within that
<subsection/> i.e within that page. If not we want to just display
'refer fig' text WITHOUT a href.

2. Out 2nd problem is the <a href..> and <figure> can appear anywhere
within the subsection. So, i need to know from whichever child level
i found <a type="figure" href="FIG007_001">, scan to its parent
<subsection> and check whether any of its child (any level again)
contains the <Figure id="FIG007_001"/>. If so, use href, else strip
out href. Basically to find whether both <a href> and corresponding
<figure> are present within 'that' single <SubSection/>

Example: In the xml, 

<a type="figure" href="FIG007_00Y">Figure Y</a> is VALID as <Figure
id="FIG007_00Y"/> also appears in the same <SubSection/>

so, i output <a href="...">Figure Y</a> in html

while,
<a type="figure" href="FIG007_00X">Figure X</a> is NOT valid since
<Figure id="FIG007_00X"> appears in different <SubSection
id="SEC007_001_002">

so, here i should output without <a href> tag.

Now, i don't know what code will achieve this as figure referece as
well <fig> element appears at diffrent levels. Pls suggest. 

<root>
<Section>

<SubSection id="SEC007_001_001">
	<Title>Activity 1</Title>
	<Activity id="007_001">
		<Question>
			<Paragraph>Refer <a type="figure" href="FIG007_001">Figure 1</a>
and take a couple of minutes to think about what you understand by
the word strategy.</Paragraph>
		</Question>
		<Discussion>
			<SubHeading>Commentary</SubHeading>
			<Paragraph>The first context in .... here also the <a
type="figure" href="FIG007_00X">Figure X</a> can be
refered.</Paragraph>
		</Discussion>
	</Activity>
	<Paragraph>As we mentioned in the introduction, <a type="figure"
href="FIG007_00Y">Figure Y</a> can be refered
something....</Paragraph>
	<Figure id="FIG007_00Y">
		<Image id="FIG007_00Y" src="B700_3_00Y.jpg"/>
		<Caption><b>Figure Y</b>: An organisation's stakeholders</Caption>
		<Description>blah blah....</Description>
	</Figure>
	<BulletedList>
		<ListItem>...strategy</ListItem>
		<ListItem>Second, <a type="figure" href="FIG007_00Y">Figure Y</a>
can be refered here too.</ListItem>
	</BulletedList>
</SubSection>

<SubSection id="SEC007_001_002">
	<Title/>
	<Figure id="FIG007_00X">
		<Image id="FIG007_00X" src="B700_3_00X.jpg"/>
		<Caption><b>Figure X</b>: An organisation's stakeholders</Caption>
		<Description>blah blah....</Description>
	</Figure>
</SubSection>


Pls ignore spell / case mistakes. xslt 2 answer also welcome - just
for my knowledge. 

Thanks in advance.
karl


		
___________________________________________________________ 
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

Current Thread