Как многие, я использовал и злоупотребил доступом за эти годы, всегда чувствовал себя немного грязным хотя... Я чувствовал себя немного лучше об этом, когда я столкнулся с этим сообщением Rob Conery недавно:
http://blog.wekeroad.com/blog/hacking-your-vote/
никогда не мечтал бы об использовании доступа в системе голосования. Страшный.
XPath contains the substring-after
function which returns the string following the first occurrence of another string. This isn't enough by itself, but a template such as the following might do it:
<xsl:template name="filename-only">
<xsl:param name="path" />
<xsl:choose>
<xsl:when test="contains($path, '\')">
<xsl:call-template name="filename-only">
<xsl:with-param name="path" select="substring-after($path, '\')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$path" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
The set of string functions available is not terribly extensive, but I've found that it is good enough for most applications that you'll need in XSLT.
Да, см. общий анализатор LR (1), реализованный в XSLT 2.0. (всего в 245 строках).
Я реализовал с его помощью парсер для JSON и парсер для XPath 2.0 - полностью в XSLT.
XSLT with the help of XPath 2.0 and its various string functions helps it deal with this type of things.
Example:
Assuming the path [to jpg file] mentioned in question comes from an xml snippet similar to
...
<For_HTML>
<Image1>
<Path>C:\Documents and Settings\me\Desktop\xml export\cd000402.jpg</Path>
<Description>Photo of the parking lot</Description>
<Width>123</Width>
...
</Image1>
</For_HTML>
XSLT snippet would look something like
<xsl:template match='//For_HTML/Image1'>
<img src='http://myNewServer.com/ImageBin/{substring-after(./Path,"\xml export\")}'
alt='{./Description}'
width=' .... you got the idea'
/>
</xsl:template>
Note: didn't have time to test; but that looks about right.
This is a little beyond the scope of the question, but Michael Kay has an excellent paper on using XSLT 2 to parse pure text into XML.