5.txt

来自「《JAVA WEB服务应用开发详解》代码」· 文本 代码 · 共 52 行

TXT
52
字号

例程5-1
<?xml-stylesheet type="text/xml" href="#style1"?>
<doc>
  <head>
    <xsl:stylesheet id="style1" version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <xsl:import href="doc.xsl"/>
      <xsl:template match="id(''''foo'''')">
        <fo:block font-weight="bold">
          <xsl:apply-templates/>
        </fo:block>
      </xsl:template>
      
      <xsl:template match="xsl:stylesheet">
        <!-- ignore -->
      </xsl:template>
    </xsl:stylesheet>
  </head>
  <body>
    <para id="foo">
      ...
    </para>
  </body>
</doc>
例程5-2
<?xml version="1.0"?>
<investment>
  <type>stock</type>
  <name>Microsoft</name>
  <price type="high">100</price>
  <price type="low">94</price>
</investment>
例程5-3
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="investment">
    <xsl:element name="{type}">
      <xsl:attribute name="name" >
        <xsl:value-of select="name"/>
      </xsl:attribute>
      <xsl:for-each select="price">
        <xsl:attribute name="{@type}" >
          <xsl:value-of select="."/>
        </xsl:attribute>
      </xsl:for-each>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?