다른 xml을 생성해야하는 xml과 xsl이 있지만 'xmlns'때문에 빈 xml이 생성됩니다. XML의 루트에 'xmlns'가 없으면 정상적으로 작동합니다. 다음 XSL은 아직 완전한 버전이 아닙니다. 더 많은 논리를 넣어야하지만 'xmlns'때문에 여기에 갇혀 있습니다.네임 스페이스에서 요소 선택/일치
Java API를 사용하여이 XML 및 XSL로 다른 XML을 생성하고 있습니다. 누군가가 xmlns 때문에 요소를 일치시킬 수없는 이유와 해결 방법을 말할 수 있습니까?
감사합니다.
XML :
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://xmlns.company.com/config">
<subi-config>
<primary-data-source>Repository</primary-data-source>
<instance>
<name>agent1</name>
<address>localhost</address>
<port>8080</port>
<admin-username>admin</admin-username>
</instance>
</subi-config>
</config>
XSL :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://xmlns.company.com/config">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="config"/>
</xsl:template>
<xsl:template match="config">
<config>
<sub-config>
<primary-data-source><xsl:value-of select="sub-config/primary-data-source"/></primary-data-source>
<xsl:apply-templates select="sub-config"/>
</sub-config>
</config>
</xsl:template>
<xsl:template match="sub-config">
<xsl:for-each select="instance">
<instance>
<name><xsl:value-of select="name"/></name>
<address><xsl:value-of select="address"/></address>
<port><xsl:value-of select="port"/></port>
<admin-username><xsl:value-of select="admin-username"/></admin-username>
</instance>
</xsl:for-each>
</xsl:template>
거의 모든 XSLT 질문은 "xml을 다른 xml로 변환"에 관한 내용이므로 제목을 수정했습니다. 대답에 대해 –