root.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Project>
<PropertyGroup>
<ApplicationName>application</ApplicationName>
</PropertyGroup>
<Import Project="project1.xml"/>
<Import Project="project2.xml"/>
</Project>
project1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Project>
<PropertyGroup>
<ApplicationName>project1</ApplicationName>
</PropertyGroup>
<Import Project="project3.xml"/>
</Project>
project2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Project>
<PropertyGroup>
<ApplicationName>project2</ApplicationName>
</PropertyGroup>
</Project>
project3.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Project>
<PropertyGroup>
<ApplicationName>project3</ApplicationName>
</PropertyGroup>
</Project>
では、これはおそらくそのようなものですか?
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<projects>
<!--<xsl:sequence select="test:project(document-uri(.), /Project)" />-->
<xsl:apply-templates select="/Project">
<xsl:with-param name="cur-path" select="document-uri(.)" />
</xsl:apply-templates>
</projects>
</xsl:template>
<xsl:template match="Project">
<xsl:param name="cur-path" as="xs:anyURI" />
<project path="{$cur-path}">
<name><xsl:value-of select="//ApplicationName" /></name>
</project>
<xsl:for-each select="//Import">
<xsl:variable name="path" select="resolve-uri(@Project, $cur-path)" />
<xsl:apply-templates select="document(@Project)/Project">
<xsl:with-param name="cur-path" select="$path" />
</xsl:apply-templates>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
root.xmlに対して実行すると、次のようになります。
<?xml version="1.0" encoding="UTF-8"?>
<projects xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:test="urn:test">
<project path="file:/C:/Dropbox/Public/xsl/recursive/root.xml">
<name>application</name>
</project>
<project path="file:/C:/Dropbox/Public/xsl/recursive/project1.xml">
<name>project1</name>
</project>
<project path="file:/C:/Dropbox/Public/xsl/recursive/project3.xml">
<name>project3</name>
</project>
<project path="file:/C:/Dropbox/Public/xsl/recursive/project2.xml">
<name>project2</name>
</project>
</projects>