XML 到 HTML:输出文字子节点
最有效的 XSL 是什么
<matflash label="popup" btn-label="Interview Transcript">
<flashtext><a href="/education/resources/students/video_cases/protected/ece/product/media/508_Guidance_Transcript.doc">Download Transcript</a></flashtext>
<flashtext class="H1">Linda Rudolph - Teacher</flashtext>
<flashtext class="H1">Little Sprouts, Methuen School</flashtext>
<flashtext><b>Interviewer:</b> Linda, could you start by describing to me what you think the basis of a well-managed classroom is. Describe in your own words, what you think the basis of a well managed classroom is? What helps you get there?</flashtext>
<flashtext><b>Linda:</b> I think just having a well managed classroom is just having good expectations so that for the children, that they know their limits, what is expected of them, what is just being able to tell them, "Okay, this is what we're doing today.", and then just set it up for them and then they know they can accomplish it, just not having any mixed messages for them.</flashtext>
<flashtext><b>Linda:</b> Having a well managed classroom is just having a really good curriculum that the teacher's can follow and teach the children so that they're interested and they know exactly what's expected of them and then the management comes from them just knowing what's expected of them, just setting up classroom rules and everybody being able to follow them and knowing what's expected.</flashtext>
...
</matflash>
将此 XML 转换为此 HTML 的
<div id="interview">
<div><a href="/education/resources/students/video_cases/protected/ece/product/media/508_Guidance_Transcript.doc">Download Transcript</a></div>
<div class="H1">Linda Rudolph - Teacher</div>
<div class="H1">Little Sprouts, Methuen School</div>
<div><b>Interviewer:</b> Linda, could you start by describing to me what you think the basis of a well-managed classroom is. Describe in your own words, what you think the basis of a well managed classroom is? What helps you get there?</div>
<div><b>Linda:</b> I think just having a well managed classroom is just having good expectations so that for the children, that they know their limits, what is expected of them, what is just being able to tell them, "Okay, this is what we're doing today.", and then just set it up for them and then they know they can accomplish it, just not having any mixed messages for them.</div>
<div><b>Linda:</b> Having a well managed classroom is just having a really good curriculum that the teacher's can follow and teach the children so that they're interested and they know exactly what's expected of them and then the management comes from them just knowing what's expected of them, just setting up classroom rules and everybody being able to follow them and knowing what's expected.</div>
...
</div>
:我在使用
或
时遇到问题显示flashtext的文字子节点(标签和文本)。
Whats the most effcient XSL for transforming this XML:
<matflash label="popup" btn-label="Interview Transcript">
<flashtext><a href="/education/resources/students/video_cases/protected/ece/product/media/508_Guidance_Transcript.doc">Download Transcript</a></flashtext>
<flashtext class="H1">Linda Rudolph - Teacher</flashtext>
<flashtext class="H1">Little Sprouts, Methuen School</flashtext>
<flashtext><b>Interviewer:</b> Linda, could you start by describing to me what you think the basis of a well-managed classroom is. Describe in your own words, what you think the basis of a well managed classroom is? What helps you get there?</flashtext>
<flashtext><b>Linda:</b> I think just having a well managed classroom is just having good expectations so that for the children, that they know their limits, what is expected of them, what is just being able to tell them, "Okay, this is what we're doing today.", and then just set it up for them and then they know they can accomplish it, just not having any mixed messages for them.</flashtext>
<flashtext><b>Linda:</b> Having a well managed classroom is just having a really good curriculum that the teacher's can follow and teach the children so that they're interested and they know exactly what's expected of them and then the management comes from them just knowing what's expected of them, just setting up classroom rules and everybody being able to follow them and knowing what's expected.</flashtext>
...
</matflash>
to this HTML:
<div id="interview">
<div><a href="/education/resources/students/video_cases/protected/ece/product/media/508_Guidance_Transcript.doc">Download Transcript</a></div>
<div class="H1">Linda Rudolph - Teacher</div>
<div class="H1">Little Sprouts, Methuen School</div>
<div><b>Interviewer:</b> Linda, could you start by describing to me what you think the basis of a well-managed classroom is. Describe in your own words, what you think the basis of a well managed classroom is? What helps you get there?</div>
<div><b>Linda:</b> I think just having a well managed classroom is just having good expectations so that for the children, that they know their limits, what is expected of them, what is just being able to tell them, "Okay, this is what we're doing today.", and then just set it up for them and then they know they can accomplish it, just not having any mixed messages for them.</div>
<div><b>Linda:</b> Having a well managed classroom is just having a really good curriculum that the teacher's can follow and teach the children so that they're interested and they know exactly what's expected of them and then the management comes from them just knowing what's expected of them, just setting up classroom rules and everybody being able to follow them and knowing what's expected.</div>
...
</div>
I'm having trouble using <xsl:value-of>
or <xsl:copy>
to display the literal child nodes (tag and text) of flashtext.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下样式表:
应用于源文档时产生以下结果:
请注意使用标识转换来复制
flashtext
节点下的所有元素。这适用于您的输入,但如果您不想复制matflash
和flashtext
上方或下方的元素,则需要进行调整。一如既往,不同的要求会导致不同的解决方案。编辑:经过深思熟虑,如果您只想复制
flashtext
下面的所有内容,并且有一些内容在更大的文档中仍然有效,那么标准身份转换模板可以替换为单个copy-of
:...产生相同的输出。
The following stylesheet:
Produces the following result when applied to your source document:
Note the use of the identity transform to copy through all elements below the
flashtext
nodes. This works with your input, but would need to be adjusted if you had elements above or belowmatflash
andflashtext
that you did not want to copy through. As always, different requirements result in different solutions.Edit: Upon reflection, if you just want to copy everything below the
flashtext
and have something that still works in a larger document, then the standard identity transform template can be replaced with a singlecopy-of
:...which produces the same output.