ตัวแปลง xsl:value-of

คำนิยามและการใช้งาน

<xsl:value-of> อาจดึงค่าของจุดหมายที่เลือก

<xsl:value-of> อาจใช้เพื่อเลือกค่าขององค์ประกอบ XML และออกเสียงมัน

หมายเหตุ:ค่าของคุณค่า select ของแอ็กเซส (จำเป็น) คือ XPath แอ็กเซส ที่ทำงานเหมือนการตำหนิระบบไฟล์ ตัวอย่าง ใช้สลักเลื่อนเลือกได้ที่ย่อย

วลี

<xsl:value-of
select="expression"
disable-output-escaping="yes|no"/>

attribute

attribute ค่า คำอธิบาย
select expression จำเป็น XPath แอ็กเซส กำหนดจากตำแหน่ง/อัตราะบุใดที่จะดึงค่า
disable-output-escaping
  • yes
  • no

ค่าเริ่มต้นคือ "no"。

ถ้าค่าเป็น "yes" ข้อความที่สร้างโดย <xsl:text> จะไม่มีการเคลื่อนย้ายในการออกเสียง。

เช่น ถ้าค่าตั้งเป็น "yes" จะไม่มีการแปลงเชิงข้อความของ "<"。

ถ้าค่าตั้งเป็น "no" จะถูกออกเสียงเป็น "<"。

ตัวอย่าง

ตัวอย่าง 1

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<xsl:template match="/">
 <html>
 <body>
   <h2>My CD Collection</h2>
   <table border="1">
     <tr bgcolor="#9acd32">
       <th>Title</th>
       <th>Artist</th>
     </tr>
     <tr>
      <td><xsl:value-of select="catalog/cd/title"/></td>
      <td><xsl:value-of select="catalog/cd/artist"/></td>
     </tr>
   </table>
 </body>
 </html>
</xsl:template>
</xsl:stylesheet>

查看 XML 文件查看 XSL 文件查看結果

ตัวอย่าง 2

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<xsl:template match="/">
  <html>
  <body>
    <h2>My CD Collection</h2>
    <table border="1">
      <tr bgcolor="#9acd32">
        <th>Title</th>
        <th>Artist</th>
      </tr>
      <xsl:for-each select="catalog/cd">
      <tr>
        <td><xsl:value-of select="title"/></td>
        <td><xsl:value-of select="artist"/></td>
      </tr>
      </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

查看 XML 文件查看 XSL 文件查看結果