|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] re: Key()
Hello,
Thank you very much Jeni and Francis for your help.
I really appreciated your friendly response. I am still
grappling with some aspects of the problem.
I have been drawing result trees and applying XPath expressions
in an endeavour to fully understand how my use of the key()
function is working. But still the outcome is not quite right.
Not only is there an ordering problem but also my index
seems to contain only a duplication of the first paragraph.
Perhaps I am missing something obvious?
It is important that I am able to mark a paragraph for the
inclusion into one or many resulting documents.
Thank you
Rhonda
PRECEDING-SIBLING
===================
temp.xml
-------
<Template>
<Destination>
<Target doc="contract"/>
<Target doc="advice"/>
<Target host="true"/>
<Section><SectionHeading>My Heading
</SectionHeading></Section>
<Para>
This paragraph appears in both the contract
and advice documents and is only included
for those customers hosting.
</Para>
<Para>
Blah, Blah
</Para>
</Destination>
<Destination>
<Target doc="contract"/>
<Target host="true"/>
<Para>
This paragraph will appear in only the contract
document for those customers hosting.
</Para>
<Para>
Blah
</Para>
</Destination>
</Template>
Transform.xsl
-----------
<xsl:key name="blueprint" match="Para"
use="concat(preceding-sibling::Target/@doc, '-',
preceding-sibling::Target/@host)"/>
<xsl:template match="Template|Section|SectionHeading
|Content|Table">
<xsl:element name="{name()}">
<xsl:copy-of select="attribute::node()"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="Para"/>
<xsl:template match="Destination">
<xsl:value-of select="key('blueprint',
'contract-true')"/>
<xsl:apply-templates/>
</xsl:template>
output.xml
--------
<Template>
This paragraph appears in both the contract
and advice documents and is only included
for those customers hosting.
<Section><SectionHeading>My Heading
</SectionHeading></Section>
This paragraph appears in both the contract
and advice documents and is only included
for those customers hosting.
</Template>
ANCESTOR
==========
I changed the source tree refering to an ancestor
rather than a preceding-sibling and still the
output was not right?
temp.xml
-------
<Template>
<Destination>
<Target doc="contract">
<Target doc="advice">
<Target host="true">
<Section><SectionHeading>
My Heading
</SectionHeading></Section>
<Para>
This paragraph appears in both the contract
and advice documents and is only included
for those customers hosting.
</Para>
<Para>
Blah, Blah
</Para>
</Target>
</Target>
</Target>
... Similar for next <Destination>
</Destination>
</Template>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








