0
XSLT를 사용하여 한 XML에서 다른 XML로 변환해야합니다.XSLT : 속성이 새 노드 추가
<?xml version="1.0" encoding="UTF-8"?>
<manifest identifier="eXescorm_quiz4823c6301f3d3afc1c1f"
xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"
xmlns:adlcp="http://www.adlnet.org/xsd/adlcp_rootv1p2"
xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<resources>
<resource identifier="RES22" type="webcontent" href="index.html">
<file href="index.html"/>
<file href="common.js"/>
</resource>
</resources>
</manifest>
원하는 출력 : 어느 곳-이
내 입력 파일 appears- 나는 <resource>
태그 안에 속성으로 두 개의 새로운 노드 <file href="new1.js">
및 <file href="new2.js">
을 추가해야
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"
identifier="eXeorm_sample4823c6301f29a89a4c1f"
xmlns:adlcp="http://www.adlnet.org/xsd/adlcp_rootv1p2"
xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<resources>
<resource identifier="RES22" type="webcontent" href="index.html">
<file href="index.html"/>
<file href="common.js"/>
<file href="new1.js"/>
<file href="new2.js"/>
</resource>
</resources>
</manifest>
내 XSLT :
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.imsglobal.org/xsd/imscp_v1p1"
xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"
exclude-result-prefixes="xhtml">
<xsl:output method="html" indent="yes" encoding="UTF-8"/>
<xsl:strip-space elements="*" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xhtml:resource">
<file href="new1.js"/>
<file href="new2.js"/>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
그러나 새 파일 노드는 추가하지 않습니다. 감사합니다.
고마워요. 그것은 완벽하게 작동합니다! :) – RahulD