John,
Your question has a simple answer, but it also contains a possible "gotcha"
that is potentially very important.
At 01:33 PM 2/4/2005, you wrote:
I imagine this is a common question and I am sure I could solve it; I am
hoping someone can point me at something tested against similar requirements.
If I have a variable containing a string such as:
/a/b/c
What is the most efficient way to create a new variable with with the string:
/item[(_at_)name='a']/item[(_at_)name='b']/item[(_at_)name='c']
If the result string is exactly as you've said, that is every substring
delimited by "/" in the source is wrapped in "/item[(_at_)name='" and "']" and
then spliced together, this is most easily achieved by a recursive
string-chopping template (or possibly by string-replacement functionality
in XSLT 2.0).
Such templates for string-handling in XSLT 1.0 are widely documented in the
FAQ, the archives to this list and elsewhere.
But this is for converting *strings*, and the strings you have offered
suggest that you may actually want to return *nodes* based on XPath (since
the strings you've offered happen to be XPath expressions, which return
nodes when resolved).
This is a very different thing, and probably not reasonably achievable in a
single pass in unextended XSLT.
If this is what you want to do, tell us a bit more about why: there may be
other ways of achieving your goal.
Cheers,
Wendell
======================================================================
Wendell Piez
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--