1
XML을 처음 접했을 때이 간단한 문제를 이해하지 못하는 것 같습니다 ... 노드 ID, 모델 및 모델을 가진 테이블을 가져옵니다 ... 코드가 올바르게 작동합니다 ...하지만 테이블 머리와 몸, 그 또한 "john doe"노드를 검색 .. 내가 뭔가 XPath 표현에 문제가있는 것 같아요.노드를 검색하는 Xpath xslt?
XML :
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="lab1.xsl"?>
<labs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="lab.xsd">
<lab name="FOA2A">
<responsible>
<name>John</name>
<surname>Doe</surname>
</responsible>
<computers>
<computer>
<id>C001</id>
<cpu>
<make>Intel</make>
<model>Core2duo</model>
<clockspeed>2.4</clockspeed>
</cpu>
<monitor>
<type>LCD</type>
<size>17"</size>
</monitor>
</computer>
<computer>
<id>C002</id>
<cpu>
<make>AMD</make>
<model>Quad</model>
<clockspeed>3.0</clockspeed>
</cpu>
<monitor>
<type>Plasma</type>
<size>23"</size>
</monitor>
</computer>
<computer>
<id>C003</id>
<cpu>
<make>AMD</make>
<model>DoubleQuad</model>
<clockspeed>4.0</clockspeed>
</cpu>
<monitor>
<type>LED</type>
<size>32"</size>
</monitor>
</computer>
</computers>
</lab>
</labs>
XSLT :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<head>TEST</head>
<body>
<table border="1">
<thead>
<tr>
<td>Computer ID</td>
<td>CPU</td>
<td>Monitor</td>
</tr>
</thead>
<tbody>
<xsl:apply-templates />
</tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="labs/lab/computers">
<xsl:for-each select="computer">
<tr>
<td>
<xsl:value-of select="id/text()" />
</td>
<td>
<xsl:value-of select="cpu/make/text()" />
</td>
<td>
<xsl:value-of select="cpu/model/text()" />
</td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
감사합니다. – user2228135