Hi,
I have an XML file similar to the following:
<!-- snippet -->
<selector key='USER/id' value='type1'/>
<selector key='USER/id' value='type2'/>
<selector key='USER/id' value='type3'/>
<options>
<USER>
<NAME>Bob</NAME>
<id>type1</id>
</USER>
<USER>
<NAME>Jane</NAME>
<id>type1</id>
</USER>
<USER>
<NAME>Bill</NAME>
<id>type2</id>
</USER>
<!-- ... -->
</options>
<!-- end snippet -->
What I would like to do using xslt is for each <selector> tag, look up
the tag(s) in <options> whose ids match the value of the node
distinguished by the selector's 'key' attribute, e.g. for the first
selector, I would like a node-set containing the users Bob and Jane, but
not Bill.
I need the path to the node (the selector 'key') to be specified in the
XML document, so I can't do it statically like:
<xsl:variable name="value" select="selector/@value"/>
<xsl:for-each select='options/USER/id=$value'>...</xsl:for-each>
I believe that also means I can't use xsl:key, since it must be
top-level and can't have variable names in its match attribute.
Is this possible with xslt or should I seek some other solution?
Regards,
--Mike 6 4623
Mike Grass wrote: I need the path to the node (the selector 'key') to be specified in the XML document
That's usually bad idea. XPath and XSLT don't support dynamic evaluation
of XPath expressions, so you task at ones becomes quite onerous just
because of poor design. Consider not using XPath in your data, use
traditional XML means to express relationship - hierarchy, element
names, IDs etc.
Is this possible with xslt or should I seek some other solution?
I'd go for two-step transformation - first generate XSLT stylesheet
(using XSLT again of course) with appropriate xsl:key definitions
according to selector keys and then run it.
--
Oleg Tkachenko [XML MVP] http://blog.tkachenko.com
Mike Grass wrote: I need the path to the node (the selector 'key') to be specified in the XML document
That's usually bad idea. XPath and XSLT don't support dynamic evaluation
of XPath expressions, so you task at ones becomes quite onerous just
because of poor design. Consider not using XPath in your data, use
traditional XML means to express relationship - hierarchy, element
names, IDs etc.
Is this possible with xslt or should I seek some other solution?
I'd go for two-step transformation - first generate XSLT stylesheet
(using XSLT again of course) with appropriate xsl:key definitions
according to selector keys and then run it.
--
Oleg Tkachenko [XML MVP] http://blog.tkachenko.com
Mike,
I haven't tried it, would a Custom Extension function work? http://support.microsoft.com/default...b;en-us;324899
Otherwise I agree with Oleg, I would find a different method to use...
Hope this helps
Jay
"Mike Grass" <mi**@accessdata.com> wrote in message
news:ef**************@TK2MSFTNGP11.phx.gbl... Hi,
I have an XML file similar to the following: <!-- snippet --> <selector key='USER/id' value='type1'/> <selector key='USER/id' value='type2'/> <selector key='USER/id' value='type3'/> <options> <USER> <NAME>Bob</NAME> <id>type1</id> </USER> <USER> <NAME>Jane</NAME> <id>type1</id> </USER> <USER> <NAME>Bill</NAME> <id>type2</id> </USER> <!-- ... --> </options> <!-- end snippet -->
What I would like to do using xslt is for each <selector> tag, look up the tag(s) in <options> whose ids match the value of the node distinguished by the selector's 'key' attribute, e.g. for the first selector, I would like a node-set containing the users Bob and Jane, but not Bill.
I need the path to the node (the selector 'key') to be specified in the XML document, so I can't do it statically like: <xsl:variable name="value" select="selector/@value"/> <xsl:for-each select='options/USER/id=$value'>...</xsl:for-each>
I believe that also means I can't use xsl:key, since it must be top-level and can't have variable names in its match attribute.
Is this possible with xslt or should I seek some other solution?
Regards, --Mike
Mike,
I haven't tried it, would a Custom Extension function work? http://support.microsoft.com/default...b;en-us;324899
Otherwise I agree with Oleg, I would find a different method to use...
Hope this helps
Jay
"Mike Grass" <mi**@accessdata.com> wrote in message
news:ef**************@TK2MSFTNGP11.phx.gbl... Hi,
I have an XML file similar to the following: <!-- snippet --> <selector key='USER/id' value='type1'/> <selector key='USER/id' value='type2'/> <selector key='USER/id' value='type3'/> <options> <USER> <NAME>Bob</NAME> <id>type1</id> </USER> <USER> <NAME>Jane</NAME> <id>type1</id> </USER> <USER> <NAME>Bill</NAME> <id>type2</id> </USER> <!-- ... --> </options> <!-- end snippet -->
What I would like to do using xslt is for each <selector> tag, look up the tag(s) in <options> whose ids match the value of the node distinguished by the selector's 'key' attribute, e.g. for the first selector, I would like a node-set containing the users Bob and Jane, but not Bill.
I need the path to the node (the selector 'key') to be specified in the XML document, so I can't do it statically like: <xsl:variable name="value" select="selector/@value"/> <xsl:for-each select='options/USER/id=$value'>...</xsl:for-each>
I believe that also means I can't use xsl:key, since it must be top-level and can't have variable names in its match attribute.
Is this possible with xslt or should I seek some other solution?
Regards, --Mike
You could use a variable in the xml file and send the
xpath query to the xml file.
Sonu -----Original Message----- Hi,
I have an XML file similar to the following: <!-- snippet --> <selector key='USER/id' value='type1'/> <selector key='USER/id' value='type2'/> <selector key='USER/id' value='type3'/> <options> <USER> <NAME>Bob</NAME> <id>type1</id> </USER> <USER> <NAME>Jane</NAME> <id>type1</id> </USER> <USER> <NAME>Bill</NAME> <id>type2</id> </USER> <!-- ... --> </options> <!-- end snippet -->
What I would like to do using xslt is for each <selector>
tag, look upthe tag(s) in <options> whose ids match the value of the
nodedistinguished by the selector's 'key' attribute, e.g. for
the firstselector, I would like a node-set containing the users
Bob and Jane, butnot Bill.
I need the path to the node (the selector 'key') to be
specified in theXML document, so I can't do it statically like: <xsl:variable name="value" select="selector/@value"/> <xsl:for-each
select='options/USER/id=$value'>...</xsl:for-each> I believe that also means I can't use xsl:key, since it
must betop-level and can't have variable names in its match
attribute. Is this possible with xslt or should I seek some other
solution? Regards, --Mike .
You could use a variable in the xml file and send the
xpath query to the xml file.
Sonu -----Original Message----- Hi,
I have an XML file similar to the following: <!-- snippet --> <selector key='USER/id' value='type1'/> <selector key='USER/id' value='type2'/> <selector key='USER/id' value='type3'/> <options> <USER> <NAME>Bob</NAME> <id>type1</id> </USER> <USER> <NAME>Jane</NAME> <id>type1</id> </USER> <USER> <NAME>Bill</NAME> <id>type2</id> </USER> <!-- ... --> </options> <!-- end snippet -->
What I would like to do using xslt is for each <selector>
tag, look upthe tag(s) in <options> whose ids match the value of the
nodedistinguished by the selector's 'key' attribute, e.g. for
the firstselector, I would like a node-set containing the users
Bob and Jane, butnot Bill.
I need the path to the node (the selector 'key') to be
specified in theXML document, so I can't do it statically like: <xsl:variable name="value" select="selector/@value"/> <xsl:for-each
select='options/USER/id=$value'>...</xsl:for-each> I believe that also means I can't use xsl:key, since it
must betop-level and can't have variable names in its match
attribute. Is this possible with xslt or should I seek some other
solution? Regards, --Mike . This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Johannes Lebek |
last post by:
Hi there,
somehow, I cannot access nodes that are stored in a variable. I'm using
Xalan 2.5.1 and the following commands:
================ BEGIN ====================
<xsl:variable...
|
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...
|
by: Claudio Jolowicz |
last post by:
Suppose you have this document:
<root>
<node id="1">
<node id="4"/>
<node id="5"/>
</node>
<node id="2"/>
<node id="3"/>
</root>
|
by: Oleg Konovalov |
last post by:
Hi,
I am new to XSLT, trying to significantly modify somebody
else's XSL. That is not 2.0.
I need to create min & max variable(s)
to be used in many templates and sub-templates
based on...
|
by: Ian Roddis |
last post by:
Hello,
I want to embed SQL type queries within an XML data record. The XML
looks something like this:
<DISPLAYPAGE>
<FIELD NAME="SERVER" TYPE="DROPDOWN">
<OPTION>1<OPTION>
<OPTION>2<OPTION>...
|
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...
|
by: SamStamport |
last post by:
Hello,
I have coded a C# program that passes an argument list to my XSLT file. I get no errors, but I don't get any output either.
Here's what I want to do: pass a parameter that is an XPath...
|
by: jkmyoung |
last post by:
Here's a short list of useful xslt general tricks that aren't taught at w3schools.
Attribute Value Template
Official W3C explanation and example
This is when you want to put dynamic values...
|
by: Rina0 |
last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |