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


0
joe4452 (4)
6/4/2004 1:13:08 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
437 Views

Similar Articles

[PageSpeed] 45

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
    
    
     
0
anonymous (74722)
6/4/2004 6:56:03 PM
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" <anonymous@discussions.microsoft.com> wrote in message
news:9B8A7EBD-CAB9-4BE5-976C-85778757CD43@microsoft.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
>
>
>


0
joe4452 (4)
6/9/2004 12:10:28 PM
Reply:

Similar Artilces:

Can I Build an Access Statement (in 2007) as a String and Execute
Hi, I know that I can build a SQL statement within a string and then execute it like the following: strSQL = "UPDATE tblAuditRpt " _ & "SET tblAuditRpt.AuditRptYesCount = " & lngInitialEvalCount & " " _ & "WHERE tblAuditRpt.AuditRptID=25;" CurrentDb.Execute strSQL, dbFailOnError Can I do the same with an Access statement itself? For example, How could I execute the following statement if I built it in a string? lngInitialEvalCount = DCount ("AuditDtlCnt", "AuditDetai...

Merging Dynamics.
hi, My question is related to merging dynamics of two different companies, Currently both companies are located at different geographical locations, they need to merg these databases,like ONE DYNAMICS and Multiple Companies, but the problem is that one have MC enabled the other one there is no MC, Please suggest any solution if someone have any idea. Sajid Do both Company databases have the exact same GL structure. That is the exact same segment structure and the exat same numbering system within the segments. "mbs" wrote: > hi, > > My question is related to mer...

XPath
This is a multi-part message in MIME format. ------=_NextPart_000_0043_01C44594.DDF761B0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I am new to XPath and I am stuck with an expression. I would like to = select all servers which the user subscribed to. Here is my XML: <forums> <forum> <name>AAA</name> <subscribed>1</subscribed> </forum> <forum> <name>BBB</name> <subscribed>0</subscribed> ...

building a worksheet row by row
I hope somebody can assist. My worksheet calculates rows of data, which I wish to slide into another worksheet and secure; then change the original data, slide those results under the first. Keep repeating. Is there a way to do this without manually pasting values each time? David Dave "Sliding" rows from one sheet to another would involve the use of VBA. See Ron de Bruin's site for moving/copying rows to next available empty rows. http://www.rondebruin.nl/copy1.htm Gord Dibben Excel MVP On Thu, 4 Nov 2004 14:04:03 -0800, "DaveButcher" <DaveButcher@discussio...

Building Assembly
I'm trying to build an assembly that creates a directory that is named after an attribute in opportunities. this is what I have, and it is not compiling into a dll, any advice? public string CreateDirectory(string root,string folderName) { } Luke Davis, MCSE: Security DEM Networks - Senior Systems Architect 7225 N First, Suite 105 Fresno, CA 93720 Office: 1 (559) 439-1000 Fax: 1 (866) 640-2041 www.demnetworks.com ...

Dynamics GP 10
We are getting ready to upgrade our Production server to GP 10 in a couple weeks. Some people that were at Convergence this year heard that there is a way(SQL Script) to transfer the new security that we have set up in version 10 from our Dev server to our Prod server. This would obviously save the need to re-create all the new security roles and access. I have read post that mention some tools you can purchase from vendors but we were curious about an SQL script. Has anyone used such a script to perform this task? Thanks very much Scott T On 7 May, 14:49, Scott Trenholm <bcsa...@ho...

Dynamics CRM 4 without Exchange but with Lotus Domino
Hi everyone, I'd like to know if in Dynamics CRM v4 you need exchange to route the incoming mail to the queues, because I have heard that in version 4 you don't need to have exchange server. We have Lotus Domino as email server and we'd like to get the incoming mail via E-mail Router Configuration Mnager in Dynamics CRM v4. I don't know if these steps are correct: 1. Create two profiles (one for incoming mails and one for outgoing mails) 2. Create a new deployment to connect with dynamics CRM server. 3. Load Data. 4. Modify the incoming or outgoing profile for a user or que...

Script error found during opening Dynamics
I just upgrade to the latest Canada Payroll tax update, when one of the user who sign on to Dynamics after upgrade, she got the "Internet Explorer Script Error" window pop up and saying "An error has occurred in the script on this page" Line: 335 Char: 6 Error: The data is invalid Code: 0 URL: file:///C:/Documents%20and%20Settings/UserA/Local%20Settings/Temp/tmpAD1.tmp I tried to clear all the temp file in this folder but still no luck to get rid of this message during loading Dynamics. I asked the user to click on "Yes" button to continue "D...

Building Kits
I am having trouble using the build kits tab. I went through and made sure all the components were available to build the kits. I click the build tab and the program prompts that there is enough inventory to build 2 kits. I enter 2 and then hit the build tab and then ok. When I go to the properties screen the inventory qty is still 0. I copied the kit and gave it another name and did the same process and was able to build the kits the first and only time. Any suggestions? known bug, apply the latest hotfix and you will be good to go. "akpetshop" <akpetshop@discussions.mic...

Facing Problem with Xpath if then else concept
XML File: <additionalFields> <field name="dataKey">3868</field> <field name="distribution">140</field> </additionalFields> I would like to execute following If else Xpath 2.0 statement. String text = nav.Evaluate("if(/additionalFields/ field[@name='distribution']/text() = '140') then 'C' else ' ' ").ToString(); However I am getting following error message: 'if(/additionalFields/field[@name='distribution']/text() = '140') then 'C' else ' ' ' has an...

Macro to build table
I have 6 questions that may be answered yes or no, and for the sake of keeping everything in integer form, let's assume "1" for yes and "0" for no. Depending on how a customer answers all 6 questions, they will receive a predetermined score. I am attempting to develop the answer key, so-to-speak, to refer the reps to once they are finished asking the customer these questions. I was hoping for the code that would build a macro to create this tabe for me - a table that would lay out all of the 6 question-answer combinations, like the following: Questi...

Insert Doctype Node Dynamically
I am receiving xml documents from a customer without a reference to a doctype. I know what the Doctype DTD should be need to insert the declaration as follows <?xml version="1.0" encoding="UTF-8"?> <!-- start of add validation tag --> <!DOCTYPE D1XML SYSTEM "http://url/myDTD.DTD"> <!-- end of add validation tag --> <XML.....> Using one of the provided framework classes such as XmlValidatingReader, etc.... is there a method to dynamically add a doctype reference? Or do I have to find the starting node and perform an insert to the do...

Dynamic Step Chart using range names
Let's create a step chart to illustrate Fed Funds Rates Data at http://www.federalreserve.gov/fomc/fundsrate.htm I create a new book and save it as "Step.xls" (a short name is good idea... see at III) | A B --|----------- ---- 1| Date Fed 2|03-Jan-2000 5.50 3|02-Feb-2000 5.75 4|21-Mar-2000 6.00 5|16-May-2000 6.50 6|03-Jan-2001 6.00 7|31-Jan-2001 5.50 8|15-Feb-2001 5.50 9| II. I have to define Range Names with Insert,Name,Define... 1. Date: =OFFSET(Sheet1!$A$2,0,0,COUNTA(Sheet1!$A:$A)-1,1) => I start f...

xy scatter source from dynamic range
here is some code from a macro i am making. i would like it to make an xy chart with my xvalues and yvalues range. these ranges are not side by side. as well this is usually creating seperate chart sheets not placing it on the worksheet id like. and where would i put .top,.left in this to properly place it. thanks very much Charts.Add ActiveChart.ChartType = xlXYScatter ActiveChart.SetSourceData Source:=series(Assay_Solutionscrollzoomindynrange.xls! xvalues,Assay_Solutionscrollzoomindynrange.xls!xvalues,1) _ PlotBy:=xlColumns With ActiveChart.SeriesCollection.NewSerie...

Error when building payroll build
One of my users is continuously getting an error when clicking OK on Calculate Payroll Checks. The error is - The checks cannot be calculated. Errors were found when building the checks. All other users can build the exact same build with no issues. What could be the issue here? Jack-One thing you may want to check is compare the users security. One user may/may not have rights to benefits/deductions/batches, etc. "Jack Tundra" wrote: > One of my users is continuously getting an error when clicking OK on > Calculate Payroll Checks. The error is - The checks cannot b...

Entourage Build Information
Processor: Power PC Is there a matrix of Entourage versions and their respective build numbers anyone can provide? This information would be of great use in troubleshooting client/server issues. Thanks in advance, Chris I haven't checked specifically for Entourage, but Wikipedia usually has such data published - you might check there. HTH |:>) Bob Jones [MVP] Office:Mac On 11/13/08 3:24 PM, in article 59b61e39.-1@webcrossing.caR9absDaxw, "chrisxmartinez@officeformac.com" <chrisxmartinez@officeformac.com> wrote: > Processor: Power PC > > Is there a ma...

Error trying to configure MS Dynamics CRM for Outlook (CRM 4.0)
Hello to all..! I have an error trying to configure MS Dynamics CRM for Outlook on a Windows VISTA w/ Office 2007 computer. The architecture is: -A server running CRM 4.0 (all roles except SQL Database): crmserv.domain.com -Another Server running SQL Server 2005 with Default Instance hosting CRM Databases: sqlserv.domain.com -The CRM 4.0 web site was installed on TCP port 5555, but later I changed to 80. I changed the registry keys, and ran the CRM Deployment Config Tool in accordance with the procedure recommended for this scenario. Now, I need to configure MS CRM for Outlook on a Wind...

using xml to build ASP.NET applications
hiya, ATM, I use vis studio to drag and drop controls on to my web forms. Apparently, an app can be built via XML and XSLT.I've been googling, but I'm still none the wiser as to why people would go to a low level of xml when they could use the IDE? Is it because: 1) the same xml can be used to build cross-platform apps? 2) it performs better (maybe there is less metadata if done in this way)? 3) it is easier to modify using XSLT than it is to go in and manually alter controls that have been dropped onto a webform? Can anyone give me a clue? Also, the people that use XML to build t...

Dynamically Add fields/controls to reports
Hello, I've not much experience with building reports in MsAccess. Can one dynamicall add fields/controls to reports from a vba module such as that linked to a form? i.e. do processing . . .set a sql string as a report's recordsource, then have the fields of the recordsource added or displayed in the report. I want to do this without having predefined the report content/format, etc. Can someone give me information or point me to information on this? Part of my reason for persuing this data display method is that there doesn't seem to be a grid control for dis...

Build
Hi, I am experiencing some problems building a solution. This project previuosly ran in Visual C++ 6, but I decided to upgrade to Visual Studio 2005 - which I now regret. ------ Build started: Project: Misc, Configuration: Debug Win32 ------ Compiling... StdAfx.cpp c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxv_w32.h(228) : error C2065: 'DWORD_PTR' : undeclared identifier c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxv_w32.h(228) : error C2143: syntax error : missing ';' before 'GetWindowThreadProcessId' c:\program files\microso...

How to build only usbdisk6.dll
Hello, I have to modify ScsiTestUnitReady() in the usbdisk6.dll. I know that it is public code and that I have to clone the component. Before cloning the component I want to try my solution and i want to see if it works so I want to modify the public code (I have a backup). How can I build and sysgen only the usbdisk6.dll ? Thanks, Paolo -- Paolo Patierno Embedded Software Engineer Paolo: Cloning the code for that should only take a few minutes. http://geekswithblogs.net/BruceEitman/archive/2008/07/02/platform-builder-clone-public-code.aspx is for a different set of c...

Versioning on Build
Hi, I would love to be able to have the build number increment each time I compile, but I am not familiar with the correct way to do versioning in C++. I have VS 2005 Pro, and in a header, I have this: #define VERSION_MAJOR 1 #define VERSION_MINOR 0 #define VERSION_BUILD 200 // Magic to get the preprocessor to do what we want #define lita(arg) #arg #define xlita(arg) lita(arg) #define cat3(w,x,z) w##.##x##.##z##\000 #define xcat3(w,x,z) cat3(w,x,z) #define VERSION_STRING xlita(xcat3(VERSION_MAJOR,VERSION_MINOR,VERSION_BUILD)...

Tempate Building How-To's?
I've been tasked with converting our company's current set of collateral (mostly in Adobe InDesign) into user-friendly Word Templates (v 2007). I'm fairly comfortable in Word, but not really skilled at creating a master template file that will be widespread used. For example, I don't need help on *how* to create a table... I need to know what is the benefit of a table vs. a 3 column page... or is there a different way to do this. I run into multiple ways to do something, and wonder what way is best, from the standpoint of multiple people using this template. Do y...

Running Calculations to build chart
I have the following columns: Job Title, Week, Total People The data looks like this: Job Title Week Total People PM W2 1 Tech Edit W3 5 Net Engineer W2 2 Programmer W12 10 Programmer2 W1 5 ..... I have a named range of weeks, W1, W2, W3, W4, W5, W6, W6, W8, W8, W10, W11, W12, named "weeks". I'm trying to build a chart to show the total number of people for each week. So I need to total up all the W1s, W2s, etc. to display my chart. Hi - I am using Excel 200. Select your Data > Job Title ...

Duplicate Transactions not Fixed with Build 1105
Was hoping this fix would deal with the duplicate transaction issues that occur when using Online Update with accounts that are updated via Yodlee... it doesn't appear that it does. Still getting duplicates... maybe they will stop with yesterdays duplicate... I suppose we will see tomorrow. Larry ...