473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Build up xpath dynamically in xslt

After a bit of research I think what I'm trying to do with xslt can't be
done, but someone may have some pointers.

I have 2 sections in my xml - 1 with properties the 2nd with image path data
each property can have more than 1 set of image path nodes

What I'm trying to do is transform the property data into the format I
require at the same time finding any associatted image paths

Here's my xml

<web_transfer>
<property>
<uniquereferenceid>1a</uniquereferenceid>
....
</property>
<property>
<uniquereferenceid>2a</uniquereferenceid>
....
</property>

<images>
<uniquereferenceid>1a</uniquereferenceid>
<imageurl>http://www.com/testimage1.jpg</imageurl>
</images>
<images>
<id>636</id>
<uniquereferenceid>2a</uniquereferenceid>
<imageurl>http://www.com/testimage2.jpg</imageurl>
</images>
<web_transfer>

An xpath like
/web_transfer/images[uniquereferenceid='1a'][position()=1]/imageurl
works fine, when used outside my xslt.

In my xslt

<xsl:template match="/">
<xsl:for-each select="web_transfer/property">
<xsl:variable name="myString1">
<xsl:value-of
select="/web_transfer/images[uniquereferenceid=uniquereferenceid][position()
=1]/imageurl"/>
</xsl:variable>

<image1>
<xsl:value-of select="$myString1"/>
</image1>

</xsl:for-each>
</xsl:template>

Hoping that the bit [uniquereferenceid=uniquereferenceid] would get filled
in to be [uniquereferenceid=1a] etc
It isn't and I don't get any data back

Any suggestions appreciatted
Thanks
Nov 12 '05 #1
4 2424
i don't think you can do that in XPath 1.0. you might have to look for some extensions
http://www.dpawson.co.uk/xsl/sect2/nono.html#d1761e3

http://www.exslt.org/dyn/functions/evaluate/index.htm

----- Joe Gass wrote: ----

After a bit of research I think what I'm trying to do with xslt can't b
done, but someone may have some pointers

I have 2 sections in my xml - 1 with properties the 2nd with image path dat
each property can have more than 1 set of image path node

What I'm trying to do is transform the property data into the format
require at the same time finding any associatted image path

Here's my xm

<web_transfer><property><uniquereferenceid>1a</uniquereferenceid
...
</property><property><uniquereferenceid>2a</uniquereferenceid
...
</property><images><uniquereferenceid>1a</uniquereferenceid><imageurl>http://www.com/testimage1.jpg</imageurl></images><images><id>636</id><uniquereferenceid>2a</uniquereferenceid><imageurl>http://www.com/testimage2.jpg</imageurl></images><web_transfer

An xpath lik
/web_transfer/images[uniquereferenceid='1a'][position()=1]/imageur
works fine, when used outside my xslt

In my xsl

<xsl:template match="/"><xsl:for-each select="web_transfer/property"><xsl:variable name="myString1"><xsl:value-o
select="/web_transfer/images[uniquereferenceid=uniquereferenceid][position(
=1]/imageurl"/></xsl:variable><image1><xsl:value-of select="$myString1"/></image1></xsl:for-each></xsl:template

Hoping that the bit [uniquereferenceid=uniquereferenceid] would get fille
in to be [uniquereferenceid=1a] et
It isn't and I don't get any data bac

Any suggestions appreciatte
Thank

Nov 12 '05 #2
i don't think you can do that in XPath 1.0. you might have to look for some extensions
http://www.dpawson.co.uk/xsl/sect2/nono.html#d1761e3

http://www.exslt.org/dyn/functions/evaluate/index.htm

----- Joe Gass wrote: ----

After a bit of research I think what I'm trying to do with xslt can't b
done, but someone may have some pointers

I have 2 sections in my xml - 1 with properties the 2nd with image path dat
each property can have more than 1 set of image path node

What I'm trying to do is transform the property data into the format
require at the same time finding any associatted image path

Here's my xm

<web_transfer><property><uniquereferenceid>1a</uniquereferenceid
...
</property><property><uniquereferenceid>2a</uniquereferenceid
...
</property><images><uniquereferenceid>1a</uniquereferenceid><imageurl>http://www.com/testimage1.jpg</imageurl></images><images><id>636</id><uniquereferenceid>2a</uniquereferenceid><imageurl>http://www.com/testimage2.jpg</imageurl></images><web_transfer

An xpath lik
/web_transfer/images[uniquereferenceid='1a'][position()=1]/imageur
works fine, when used outside my xslt

In my xsl

<xsl:template match="/"><xsl:for-each select="web_transfer/property"><xsl:variable name="myString1"><xsl:value-o
select="/web_transfer/images[uniquereferenceid=uniquereferenceid][position(
=1]/imageurl"/></xsl:variable><image1><xsl:value-of select="$myString1"/></image1></xsl:for-each></xsl:template

Hoping that the bit [uniquereferenceid=uniquereferenceid] would get fille
in to be [uniquereferenceid=1a] et
It isn't and I don't get any data bac

Any suggestions appreciatte
Thank

Nov 12 '05 #3
Thanks Tman, you're right it can't be done as I was trying to do it.

I found the solution in microsoft.public.xsl
The answer was to use <xsl:key>

Cheers

"tMan" <an*******@discussions.microsoft.com> wrote in message
news:9B**********************************@microsof t.com...
i don't think you can do that in XPath 1.0. you might have to look for some extensions. http://www.dpawson.co.uk/xsl/sect2/nono.html#d1761e34

http://www.exslt.org/dyn/functions/evaluate/index.html

----- Joe Gass wrote: -----

After a bit of research I think what I'm trying to do with xslt can't be done, but someone may have some pointers.

I have 2 sections in my xml - 1 with properties the 2nd with image path data each property can have more than 1 set of image path nodes

What I'm trying to do is transform the property data into the format I require at the same time finding any associatted image paths

Here's my xml

<web_transfer><property><uniquereferenceid>1a</uniquereferenceid>
....
</property><property><uniquereferenceid>2a</uniquereferenceid>
....
</property><images><uniquereferenceid>1a</uniquereferenceid><imageurl>http:/
/www.com/testimage1.jpg</imageurl></images><images><id>636</id><uniquerefere
nceid>2a</uniquereferenceid><imageurl>http://www.com/testimage2.jpg</imageur
l></images><web_transfer>
An xpath like
/web_transfer/images[uniquereferenceid='1a'][position()=1]/imageurl
works fine, when used outside my xslt.

In my xslt

<xsl:template match="/"><xsl:for-each select="web_transfer/property"><xsl:variable name="myString1"><xsl:value-of select="/web_transfer/images[uniquereferenceid=uniquereferenceid][position() =1]/imageurl"/></xsl:variable><image1><xsl:value-of select="$myString1"/></image1></xsl:for-each></xsl:template>
Hoping that the bit [uniquereferenceid=uniquereferenceid] would get filled in to be [uniquereferenceid=1a] etc
It isn't and I don't get any data back

Any suggestions appreciatted
Thanks

Nov 12 '05 #4
Thanks Tman, you're right it can't be done as I was trying to do it.

I found the solution in microsoft.public.xsl
The answer was to use <xsl:key>

Cheers

"tMan" <an*******@discussions.microsoft.com> wrote in message
news:9B**********************************@microsof t.com...
i don't think you can do that in XPath 1.0. you might have to look for some extensions. http://www.dpawson.co.uk/xsl/sect2/nono.html#d1761e34

http://www.exslt.org/dyn/functions/evaluate/index.html

----- Joe Gass wrote: -----

After a bit of research I think what I'm trying to do with xslt can't be done, but someone may have some pointers.

I have 2 sections in my xml - 1 with properties the 2nd with image path data each property can have more than 1 set of image path nodes

What I'm trying to do is transform the property data into the format I require at the same time finding any associatted image paths

Here's my xml

<web_transfer><property><uniquereferenceid>1a</uniquereferenceid>
....
</property><property><uniquereferenceid>2a</uniquereferenceid>
....
</property><images><uniquereferenceid>1a</uniquereferenceid><imageurl>http:/
/www.com/testimage1.jpg</imageurl></images><images><id>636</id><uniquerefere
nceid>2a</uniquereferenceid><imageurl>http://www.com/testimage2.jpg</imageur
l></images><web_transfer>
An xpath like
/web_transfer/images[uniquereferenceid='1a'][position()=1]/imageurl
works fine, when used outside my xslt.

In my xslt

<xsl:template match="/"><xsl:for-each select="web_transfer/property"><xsl:variable name="myString1"><xsl:value-of select="/web_transfer/images[uniquereferenceid=uniquereferenceid][position() =1]/imageurl"/></xsl:variable><image1><xsl:value-of select="$myString1"/></image1></xsl:for-each></xsl:template>
Hoping that the bit [uniquereferenceid=uniquereferenceid] would get filled in to be [uniquereferenceid=1a] etc
It isn't and I don't get any data back

Any suggestions appreciatted
Thanks

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
7
by: Sebastian Petzelberger | last post by:
Hi group, please give me an example of a xpath with regex or better a link with examples. Thanks in advance, Sebastian
14
by: inquirydog | last post by:
Hi- One frusterating thing for me with xsl is that I don't know how to make xslt throw some sort of exception when a value-of path does not exist. For instance, suppose I have the following...
1
by: Murtaza Tinwala | last post by:
Hi mates, I have the following problem in XSLT. I have following variables: ref-file = <path of XML document> eg "xmlDoc.xml" repeatpath = <a repeat path expressed in Xpath like /root/person >...
4
by: Son KwonNam | last post by:
In XSLT, is this possible to get value from xml using XPath which is in XSLT variable? I mean XPath strings can be dynamic while XSL Transforming. If possible, How?? Because I'm not a...
3
by: Kathy Burke | last post by:
Hi again, I'm using the following xpath (works in visualizer) with a SelectSingleNode("xpath") statement. //Station/(WI])]/@order Problem is I get an error "expression passed to this method...
0
by: Joe Gass | last post by:
After a bit of research I think what I'm trying to do with xslt can't be done, but someone may have some pointers. I have 2 sections in my xml - 1 with properties the 2nd with image path data...
6
by: dotnetnoob | last post by:
i would like to know how i can build xpath expression dynamiclly. let's say i have a following xml file: <EventEnrollment InstanceNumber = "675"> <EventSource> <ObjectReference...
1
by: Sergey Dubinets | last post by:
In effort to prioritize our goals we composed the list of random features each of them may add value to set of XSLT tools offered from Microsoft. 1. XSLTc (Compiler for XSLT...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.