473,698 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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>
<uniquereferenc eid>1a</uniquereference id>
....
</property>
<property>
<uniquereferenc eid>2a</uniquereference id>
....
</property>

<images>
<uniquereferenc eid>1a</uniquereference id>
<imageurl>htt p://www.com/testimage1.jpg</imageurl>
</images>
<images>
<id>636</id>
<uniquereferenc eid>2a</uniquereference id>
<imageurl>htt p://www.com/testimage2.jpg</imageurl>
</images>
<web_transfer >

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

In my xslt

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

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

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

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

Any suggestions appreciatted
Thanks
Nov 12 '05 #1
4 2445
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><uniqu ereferenceid>1a </uniquereference id
...
</property><prope rty><uniquerefe renceid>2a</uniquereference id
...
</property><image s><uniquerefere nceid>1a</uniquereference id><imageurl>ht tp://www.com/testimage1.jpg</imageurl></images><images> <id>636</id><uniquerefer enceid>2a</uniquereference id><imageurl>ht tp://www.com/testimage2.jpg</imageurl></images><web_tra nsfer

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

In my xsl

<xsl:template match="/"><xsl:for-each select="web_tra nsfer/property"><xsl: variable name="myString1 "><xsl:valu e-o
select="/web_transfer/images[uniquereference id=uniquerefere nceid][position(
=1]/imageurl"/></xsl:variable><i mage1><xsl:valu e-of select="$myStri ng1"/></image1></xsl:for-each></xsl:template

Hoping that the bit [uniquereference id=uniquerefere nceid] would get fille
in to be [uniquereference id=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><uniqu ereferenceid>1a </uniquereference id
...
</property><prope rty><uniquerefe renceid>2a</uniquereference id
...
</property><image s><uniquerefere nceid>1a</uniquereference id><imageurl>ht tp://www.com/testimage1.jpg</imageurl></images><images> <id>636</id><uniquerefer enceid>2a</uniquereference id><imageurl>ht tp://www.com/testimage2.jpg</imageurl></images><web_tra nsfer

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

In my xsl

<xsl:template match="/"><xsl:for-each select="web_tra nsfer/property"><xsl: variable name="myString1 "><xsl:valu e-o
select="/web_transfer/images[uniquereference id=uniquerefere nceid][position(
=1]/imageurl"/></xsl:variable><i mage1><xsl:valu e-of select="$myStri ng1"/></image1></xsl:for-each></xsl:template

Hoping that the bit [uniquereference id=uniquerefere nceid] would get fille
in to be [uniquereference id=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.publi c.xsl
The answer was to use <xsl:key>

Cheers

"tMan" <an*******@disc ussions.microso ft.com> wrote in message
news:9B******** *************** ***********@mic rosoft.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><uniqu ereferenceid>1a </uniquereference id>
....
</property><prope rty><uniquerefe renceid>2a</uniquereference id>
....
</property><image s><uniquerefere nceid>1a</uniquereference id><imageurl>ht tp:/
/www.com/testimage1.jpg</imageurl></images><images> <id>636</id><uniquerefer e
nceid>2a</uniquereference id><imageurl>ht tp://www.com/testimage2.jpg</imageur
l></images><web_tra nsfer>
An xpath like
/web_transfer/images[uniquereference id='1a'][position()=1]/imageurl
works fine, when used outside my xslt.

In my xslt

<xsl:template match="/"><xsl:for-each select="web_tra nsfer/property"><xsl: variable name="myString1 "><xsl:valu e-of select="/web_transfer/images[uniquereference id=uniquerefere nceid][position() =1]/imageurl"/></xsl:variable><i mage1><xsl:valu e-of select="$myStri ng1"/></image1></xsl:for-each></xsl:template>
Hoping that the bit [uniquereference id=uniquerefere nceid] would get filled in to be [uniquereference id=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.publi c.xsl
The answer was to use <xsl:key>

Cheers

"tMan" <an*******@disc ussions.microso ft.com> wrote in message
news:9B******** *************** ***********@mic rosoft.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><uniqu ereferenceid>1a </uniquereference id>
....
</property><prope rty><uniquerefe renceid>2a</uniquereference id>
....
</property><image s><uniquerefere nceid>1a</uniquereference id><imageurl>ht tp:/
/www.com/testimage1.jpg</imageurl></images><images> <id>636</id><uniquerefer e
nceid>2a</uniquereference id><imageurl>ht tp://www.com/testimage2.jpg</imageur
l></images><web_tra nsfer>
An xpath like
/web_transfer/images[uniquereference id='1a'][position()=1]/imageurl
works fine, when used outside my xslt.

In my xslt

<xsl:template match="/"><xsl:for-each select="web_tra nsfer/property"><xsl: variable name="myString1 "><xsl:valu e-of select="/web_transfer/images[uniquereference id=uniquerefere nceid][position() =1]/imageurl"/></xsl:variable><i mage1><xsl:valu e-of select="$myStri ng1"/></image1></xsl:for-each></xsl:template>
Hoping that the bit [uniquereference id=uniquerefere nceid] would get filled in to be [uniquereference id=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
2920
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 this, and came across a problem that I haven't been able to solve elegantly. The problem is to find "linker" vertexes that a pair of verteces from a pre-defined set. For example, if the graph verteces represent cities and edges represent flights...
7
16654
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
12175
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 line in xslt <xsl:value-of select="/blah/q" /> and my xml document does not have a node /blah/q. The output would
1
4269
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 > eg "/root/person" node = <name of a child node in repeat path> eg" "name" Now, I want to get to the 'node' in XSLT using Xpath.
4
21207
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 native English speaker, it's quite hard to make the problem clear. Please see the following example.
3
4541
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 should result in a NodeSet". Of course, that (sort of) makes sense to me now (I suppose just an attribute couldn't be a nodeset, but how would I go
0
373
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 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
6
4934
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 ObjectKey="xxxxx"> .. .. .. <EventEnrollment InstanceNumber = "676">
1
2415
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 stylesheets, that generates .NET assemblies) 2. Performance improvements in the XslCompiledTransform
0
8610
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.