0
XML 노래 가사 데이터베이스를 XSLT가있는 HTML로 변환하려고합니다. 내 XML은 다음과 같이 시작합니다 :XSLT : 네임 스페이스가 일치하지 않는 요소가 일치합니다.
<?xml version='1.0' encoding='utf-8'?>
<song xmlns="http://openlyrics.info/namespace/2009/song" version="0.8" createdIn="OpenLP 2.0.1" modifiedIn="OpenLP 2.0.1" modifiedDate="2012-03-14T02:21:52">
<properties>
<titles>
<title>Amazing Grace</title>
</titles>
<authors>
<author>John Newton</author>
</authors>
</properties>
<lyrics>
<verse name="v1">
<lines>Amazing grace, how sweet the sound<br/>That saved a wretch like me<br/>I once was lost, but now am found<br/>Was blind but now I see</lines>
위의 네임 스페이스를 내 XSLT에 추가해야한다는 것을 알고 있습니다. 시도해 보니 내 XSLT 모양은 다음과 같습니다.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:lyrics="http://openlyrics.info/namespace/2009/song">
<xsl:template match="lyrics:song">
<h3><xsl:value-of select="properties/titles/title"/></h3>
<h4><xsl:value-of select="properties/authors/author"/></h4>
<xsl:for-each select="lyrics/verse">
<xsl:copy-of select="lines" /><br /><br />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
불행히도이 코드는 여전히 작동하지 않습니다. 내 XSLT는 XML에서 xmlns 항목을 제거하고 "노래"를 직접 일치시킬 때만 작동합니다. 내가 "가사"라는 xmlns 네임 스페이스에 관해서 내가 잘못하고있는 것을 지적 할 수 있습니까? 저는 XML/XSLT에서 매우 새로 왔습니다. 미리 감사드립니다!
감사합니다. 나중에 시도해 보겠습니다. 네임 스페이스 정보는 나와 관련이 없으므로 XSLT를 사용하여 XML 시작 부분에 태그의 xmlns 정보를 제거하는 방법이 있습니까? –
brohrig
네임 스페이스 선언을 제거하는 가장 쉬운 방법은 편집기를 사용하는 것입니다. xlst를 사용하여 다음을 수행하십시오. http://stackoverflow.com/a/6253642/2115381 –