아래 xslt 코드는 아래 XML 파일에서 작동하지 않습니다. 그러나 XML 파일의 "개체"노드에서 네임 스페이스 특성을 제거하면 예상대로 작동합니다. 루트 노드에 네임 스페이스 특성이있을 때 작동하도록 xslt 코드를 수정하려면 어떻게해야합니까? 첫 번째 게시, 형식이 엉망인 경우 미안합니다. 감사합니다네임 스페이스가 루트 노드에 선언 된 경우 xslt 스크립트가 작동하지 않습니다.
XML 파일 :
<objects xmlns="http://www.spicefactory.org/parsley"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<object id="models" type="blah">
</object>
</objects>
XSLT 코드 :
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" indent="no"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="object">
<object new_attr="attr value ">
<xsl:apply-templates select="node()|@*"/>
</object>
</xsl:template>
</xsl:stylesheet>
가능한 중복 기본 네임 스페이스가 xmlns로 설정된 XML 소스] (http://stackoverflow.com/questions/1344158/xslt-with-xml-source-that-has-a-default-namespac) e-set-to-xmlns) –