473,388 Members | 1,425 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,388 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 2426
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.