想来想去,决定到这里问问,有关XSL的.100分!!ONLINE...

xiaoqu 2003-10-20 10:42:10
我用XSLT将XML文档转换到要求的XML文档格式,可是在转换过程中我发现可能是namespace的问题,使我的除了匹配根节点的模板外其他的模板得不到应用,请教高手,如何处理。
如:
<?xml version="1.0"?>
<we xmlns="urn:a">
<Do xmlns="urn:s">
<LastPrinted>2003-02-03T06:39:05Z</LastPrinted>
<Created>2001-04-09T05:53:04Z</Created>
</Do>
<Of xmlns="urn:sc">
<cd>hehe</cd>
</Of>
<Styles>
<a1>1</a1>
<a2>2</a2>
</Styles>

</we>
如何取得匹配/we/Of和we/Do 的模板,例如我想在输出的XML文档中只COPY Do元素下 的所有节点,如何写模板。
...全文
33 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoqu 2003-10-21
  • 打赏
  • 举报
回复
no more words,3k
saucer 2003-10-20
  • 打赏
  • 举报
回复
"we" node's namespace is the default namespace
<we xmlns="we"


so you will need to do

<xsl:stylesheet ...
xmlns:a="we"
...>

<xsl:apply-templates select="/a:we" />
xiaoqu 2003-10-20
  • 打赏
  • 举报
回复
aucer(思归) :还有点问题,如果元素中包含多个名字空间怎么写?例如<we xmlns="we"
xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"> 怎么得到这个匹配的节点<we>
saucer 2003-10-20
  • 打赏
  • 举报
回复
you need to define the same namespaces in XSLT, for example

<xsl:stylesheet ...
xmlns:a="urn:a"
xmlns:s="urn:s"
xmlns:sc="urn:sc"
...>

then

<xsl:apply-templates select="/a:we/sc:Of" />
<xsl:apply-templates select="/a:we/s:Do" />



8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧