i am trying to join two xml files which contains details about each other that can be linked, but i am unsure how to.
"movies.xml"
<movies>
<movie>
<title></title>
<studio><studio>
<date></date>
</movie>
</movies>
"studios.xml"
<studios>
<studio>
<name></name>
<founded></founded>
<location></location>
</studio>
</studios>
Output
<studios>
<studio>
<name></name>
<founded></founded>
<location></location>
<movie>
<name></name>
</movie>
<movie>
<name></name>
</movie>
</studio>
</studios>
I have simplified the files but still stands. My idea was using studios as the base just get the value and insert, however when it comes to joining movie to the correct studio i am confused.
I currently attempt to loop through each movie until i find the same matching name, in movies it being studio and in studios it being name
But current attempts don't work, is this way possible?
Edits: There is one studio but it can have many movies, in studios there are several studio and in movies there are several movies. If a studio has more than one movie than it can be added as name so it is possible each studio has several movies elements .
What I am attempting to do is, get all the movies and add them to the correct studio.
Dummy data: Movies.xml
<movies>
<movie>
<title>Lord of XSLT</title>
<studio>Great XML<studio>
<date>1-1-2014</date>
</movie>
<movie>
<title>On the XML</title>
<studio>XML2.0<studio>
<date>5-1-2004</date>
</movie>
<movie>
<title>On the XPath</title>
<studio>Great XML<studio>
<date>5-5-2013</date>
</movie>
</movies>
Studios.xml
<studios>
<studio>
<name>Great XML</name>
<founded>1-1-1999</founded>
<location>USA</location>
</studio>
<studio>
<name>XML2.0</name>
<founded>9-9-1998</founded>
<location>ENGLAND</location>
</studio>
</studios>
Output.xml
<studios>
<studio>
<name>Great XML</name>
<founded>1-1-1999</founded>
<location>ENGLAND</location>
<movie>
<name>Lord of XSLT</name>
</movie>
<movie>
<name>On the XPath</name>
</movie>
</studio>
<studio>
<name>XML2.0</name>
<founded>9-9-1998</founded>
<location>ENGLAND</location>
<movie>
<name>On the XML</name>
</movie>
</studio>
</studios>
Attempt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/studios">
<xsl:for-each select="studio">
<studio>
<name><xsl:value-of select="name"/></name>
<founded><xsl:value-of select="founded"/></founded>
<location><xsl:value-of select="location"/></location>
<xsl:for-each select="document('movies.xml')/movies/movie">
<movies>
</movies>
</xsl:for-each>
</studio>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
<movies>...<movie>...</movie></movies>?