0
XSLT 파일을 만들려고하고 있는데 두 파일에 네임 스페이스를 포함하지 않고 작동하도록 할 수 있지만 포함 시키면 바로 작동하지 않습니다. 여기에 제가 사용하는 예제가 있습니다.XSLT 변환은 네임 스페이스를 포함하는 방법을 해결할 수 없습니까?
내 XML 파일
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Empire sdf</title>
<artist>Bob sdf</artist>
<country>2</country>
<company>asdfs</company>
<price>12.90</price>
<year>1935</year>
</cd>
</catalog>
파일을 변환 내.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<html><body><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 version="1.0" encoding="UTF-8"?>
<html>
<body>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<tr>
<td>Empire Burlesque</td>
<td>Bob Dylan</td>
</tr>
<tr>
<td>Empire sdf</td>
<td>Bob sdf</td>
</tr>
</table>
</body>
</html>
는 아니, 난 이것에 위의 변경합니다. 내 새 XML 파일
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog
xmlns="http://www.someurl.com/v3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.someurl.com/v3.0 ../someschema.xsl"
>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Empire sdf</title>
<artist>Bob sdf</artist>
<country>2</country>
<company>asdfs</company>
<price>12.90</price>
<year>1935</year>
</cd>
</catalog>
내 새로운 변환 파일.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.someurl.com/v3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.someurl.com/v3.0 ../someschema.xsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<html><body><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>
이제 변형 된 파일에 데이터가 출력되지 않습니까? 이 질문이 기본이라면, XSLT에 대한 경험이 없으며 현재 내 머리를 감싸고 싶습니다.
이 파일을 내 xslt 파일에 추가했지만 실행 중일 때 예기치 않은 속성이 나타납니다. 내 XML 파일에 추가하면 아무런 효과가 없습니까? – Purplemonkey
예 수정 : xpath-default-namespace는 xslt 2.0 기능입니다. 죄송합니다. –
나는 페니가 가장자리에 가까워지는 것을 느낄 수있다. 당신의 도움에 감사드립니다. – Purplemonkey