Re: Generic Element to Attribute String Conversion
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 the result string is exactly as you've said, that is every substring delimited by "/" in the source is wrapped in "/item[@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.
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format