Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tricky Optimisation, Can it be done? More Expert than Beginner

Status
Not open for further replies.

simonchristieis

Programmer
Jan 10, 2002
1,144
GB
Hi all,

I have an xml file and am transforming it using xsl.
Currently using msxml parser, will need to transform using Xalan-J (xerces parser)

Within this file I have included another xsl file that I am using as a data island, however, I want to try and access the data island with values from the xml document being transformed.

Erm yeah, that's clear !

Anyway, this code below works, I want to know if I can optimise this by getting rid of the variable.

Code:
<!-- grab the name of the variable -->
<xsl:variable name="type" select="local-name(IH:envelope/IH:body/IH:instrumentSnap/*[1])"/>

<!-- then look up the message type from data island -->
<xsl:value-of select="document('GenericData.xslt')/xsl:stylesheet/Generic:messagetype/Generic:MessType[@IHMessType = $type]/@CRSDataType"/>

what I want would look sommat like this :

Code:
<xsl:value-of select="document('GenericData.xslt')/xsl:stylesheet/Generic:messagetype/Generic:MessType[@IHMessType = local-name(document(.)/IH:envelope/IH:body/IH:instrumentSnap/*[1])]/@CRSDataType"/>

Any ideas anyone ?

Thanks in advance.

Simon

 
I would say enclose the local-name() thing in curly bracket?
 
I meant this with additional quote.

[tt]<xsl:value-of select="document('GenericData.xslt')/xsl:stylesheet/Generic:messagetype/Generic:MessType[@IHMessType = local-name(document(.)/IH:envelope/IH:body/IH:instrumentSnap/*[1])]/@CRSDataType"/>[/tt]

[tt]<xsl:value-of select="document('GenericData.xslt')/xsl:stylesheet/Generic:messagetype/Generic:MessType[@IHMessType = [red]'{[/red]local-name(document(.)/IH:envelope/IH:body/IH:instrumentSnap/*[1])[red]}'[/red]]/@CRSDataType"/>[/tt]


 
Thanks tsuji, but ....

The problem lies with the focus of the expression lying within a imported document, which doesn't let me traverse back up the tree, and out of the document back into the xml file.

I can traverse the tree using :

Code:
<xsl:value-of select="document('GenericData.xslt')/xsl:stylesheet/Generic:messagetype/Generic:MessType[@IHMessType = local-name(ancestor::*[1])]/@CRSDataType"/>

but as you can see, I am still in the imported documents tree (GenericData.xslt)

I'm not holding out a lot of hope for this one!

Unless, the XML forum MVP has any more ideas ?

8^)


 
You need to use the current() function:
Code:
<xsl:value-of select="document('GenericData.xslt')/xsl:stylesheet/Generic:messagetype/Generic:MessType[@IHMessType = local-name(current()/IH:envelope/IH:body/IH:instrumentSnap/*[1])]/@CRSDataType"/>

Jon

"I don't regret this, but I both rue and lament it.
 
ps, not sure how much this optimises things

Jon

"I don't regret this, but I both rue and lament it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top