Hey guys,
I'm tying to merge two XML file for days but it doesn't work. Here is the problem:
I want to merge these XML files:
graphs.xml
<?xml version='1.0' encoding='utf-8'?>
<ph:Graphs xmlns:ph="http://www.merge.something.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<ph:Graph name="mass_spring_mo">
<ph:Element id="0" type="Mass">
<ph:Attribute>
<ph:AttributeField name="type" value="float" />
</ph:Attribute>
<ph:Port id="1" type="port">
<ph:Attribute>
<ph:AttributeField name="type" value="int" />
</ph:Attribute>
</ph:Port>
</ph:Element>
<ph:Edge id="3" sourceid="4" targetid="5" />
</ph:Graph>
</ph:Graphs>
and metamodel.xml
<?xml version='1.0' encoding='utf-8'?>
<ph:Metamodel xmlns:ph="http://www.merge.something.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ph:ElementType name="ElementType">
<ph:ElementType name="Mass">
<ph:Attribute>
<ph:AttributeField name="type" value="int" />
<ph:AttributeField name="name" value="m" />
<ph:AttributeField name="value" value="5" />
<ph:AttributeField name="send_to_graph_rewrite_engine" value="True" />
</ph:Attribute>
</ph:ElementType>
</ph:ElementType>
</ph:Metamodel>
Therefore I created an index.xml file:
<?xml version="1.0"?>
<ph:index xmlns:ph="http://www.merge.something.com">
<ph:entry>graphs</ph:entry>
<ph:entry>metamodel</ph:entry>
</ph:index>
An I started with this XSLT file:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xxmlns:ph="http://www.merge.something.com">
<xsl:output method="xml"/>
<xsl:template match="booggie:index">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="ph:index/ph:entry">
<xsl:apply-templates select="document(concat(.,'.xml'))"/>
</xsl:template>
<xsl:template match="ph:Graphs">
<xsl:value-of select="ph:Graph"/>
</xsl:template>
</xsl:stylesheet>
My disered output should be looking like that:
<?xml version='1.0' encoding='utf-8'?>
<ph:Graphs xmlns:ph="http://www.merge.something.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<ph:Graph name="mass_spring_mo">
<ph:Element id="0" type="Mass">
<ph:Attribute>
<ph:AttributeField name="type" value="float" />
</ph:Attribute>
<ph:Attribute>
<ph:AttributeField name="type" value="int" />
<ph:AttributeField name="name" value="m" />
<ph:AttributeField name="value" value="5" />
<ph:AttributeField name="send_to_graph_rewrite_engine" value="True" />
</ph:Attribute>
<ph:Port id="1" type="port">
<ph:Attribute>
<ph:AttributeField name="type" value="int" />
</ph:Attribute>
</ph:Port>
</ph:Element>
<ph:Edge id="3" sourceid="4" targetid="5" />
</ph:Graph>
</ph:Graphs>
But there is no output!? Where is error!? Can anyone help me please.
Thanks!
Bye Michael