为什么空的样式表会从XML中返回文本?

huangapple go评论107阅读模式
英文:

Why empty stylesheet returns text from XML?

问题

Empty stylesheet 返回 TEXT 值的原因是当测试文件不匹配样式表内的 xsl:template match= 值时,XSLT 会生成 TEXT 值。这个例子是一个简化的示例,有助于理解在这种情况下 XSLT 的行为。

英文:

Could you explain why empty stylesheet returns TEXT value?
The stylesheet is:

  1. <xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  2. <xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
  3. </xsl:stylesheet>

With the test file like

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <TEST>
  3. <ABC>
  4. <a>ABC</a>
  5. <b>BCD</b>
  6. <c>CDE</c>
  7. </ABC>
  8. </TEST>

Returns TEXT value:

  1. ABC
  2. BCD
  3. CDE

It is simplified example, this case happens when the test file doesn't fit xsl:template match= value inside the stylesheet.
Would be great to understand xslt behavior in that scenario.

答案1

得分: 3

因为内置模板规则

英文:

Because of built-in template rules.

huangapple
  • 本文由 发表于 2023年8月4日 22:31:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76836870.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定