XSL高手请进!我认为可能解决不了的问题

yjs_lh 2004-04-29 07:12:15
在一个XSL中,已求得一个XPATH字符串,问:如何求得此字符串指定的XPATH之值?
XSL这样写不行的:
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:output encoding="gb2312" method="html"/>
<xsl:param name="xpath" select="'/Root/Datas/Row[1]'"/>
<xsl:template match="/">
<xsl:value-of select="msxsl:node-set(xpath)"
</xsl:template>
</xsl:stylesheet>
...全文
84 6 点赞 打赏 收藏 举报
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
snowcloud2002 2004-04-30
顶一下
  • 打赏
  • 举报
回复
saucer 2004-04-30
the basic constructs are shown above or see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk30/htm/xmrefmsxslscriptelement.asp

you just need to know the XML document object model

http://msdn.microsoft.com/library/en-us/xmlsdk30/htm/xmmscxmlreference.asp?frame=true

>>>即要在引号中使用引号应该怎样写?

try

<xsl:variable name="xpath" select="'/Root/Datas/Row[Col1="aa" and Col2="bb"]'" />

then

<xsl:value-of select="user:getnodes(., $xpath)"/>
  • 打赏
  • 举报
回复
bflovesnow 2004-04-30
楼上错啦,sauser常在本版出现的,呵呵~
  • 打赏
  • 举报
回复
yjs_lh 2004-04-30
我原来也考虑过这样用。但是不知道哪里查有关</msxsl:script >的资料。
还有个问题就是如何在xpath中使用转义符呢?如
<xsl:variable name="xpath" select="'/Root/Datas/Row[Col1=\'aa\' and Col2='\bb\']'"
xpath是一个字符串。
即要在引号中使用引号应该怎样写?
  • 打赏
  • 举报
回复
mikespook 2004-04-29
sauser难得现身WEB开发啊~~~
  • 打赏
  • 举报
回复
saucer 2004-04-29
msxsl:node-set works on result-tree fragments that are not nodesets, it doesn't work on an xpath string

there is no general way to solve your problem in the current implementations, if the xpath is simple enough, you could try to write a recusive template to get the nodes one part at a time using the node names involved

but since you are using msxsl extension, consider to write a script code, like

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="http://mycompany.com/mynamespace"
version="1.0">
<msxsl:script language="JScript" implements-prefix="user">
function getnodes(nodelist, path) {
return nodelist.nextNode().selectNodes(path);
}
</msxsl:script>

<xsl:template match="/">
<xsl:value-of select="user:getnodes(., 'xxxx')"/>
</xsl:template>
</xsl:stylesheet>
  • 打赏
  • 举报
回复
相关推荐
发帖
XML/XSL
加入

8854

社区成员

XML/XSL相关问题讨论专区
申请成为版主
帖子事件
创建了帖子
2004-04-29 07:12
社区公告
暂无公告