I have this xsl file. It gets the concepts and relations from this xml file and should display it in a table but all I am getting is:
<?xml version="1.0" encoding="UTF-8"?> <table/>
Does anyone know why?
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output version="1.0" encoding="UTF-8" indent="yes" /> <xsl:strip-space elements="*"/> <xsl:key name="idkey" match="concept" use="@id" /> <xsl:template match="/"> <root> <xsl:apply-templates select="*"/> </root> </xsl:template> <xsl:template match="concept[generate-id() = generate-id(key('idkey',@id)[1])]"> <xsl:variable select="@id" name="id"/> <conceptualgraph> <graph> <xsl:attribute name="id"><xsl:value-of select="ancestor::graph/@id"/></xsl:attribute> <concept> <xsl:copy> <xsl:copy-of select="@*"/> </xsl:copy> </concept> <relation> <xsl:copy-of select="ancestor::graph/relation[contains(@id, $id)]"/> </relation> </graph> </conceptualgraph> </xsl:template> </xsl:transform>
My XML file is:
<?xml version="1.0" encoding="UTF-8"?> <conceptualgraph editor="CharGer" version="4.1.0" created="Jan 4, 2016 12:06:58 AM" modified="Jan 4, 2016 12:36:07 AM" user="Charli" wrapLabels="false" wrapColumns="30"> <graph id="401e8946:15209f3d481:-7fd9" owner="0"> <type> <label>Proposition</label> </type> <layout> <rectangle x="5.00" y="5.00" width="1200.00" height="900.00"/> <color foreground="0,94,192" background="0,94,192"/> <font name="SansSerif" style="1" size="12" /> </layout> <relation id="401e8946:15209f3d481:-7f98" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Child Of Adult</label> </type> <layout> <rectangle x="341.00" y="114.00" width="40.00" height="24.00"/> <color foreground="0,0,0" background="255,231,100"/> <font name="SansSerif" style="1" size="12" /> </layout> </relation> <relation id="401e8946:15209f3d481:-7fcc" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Parent Of Child</label> </type> <layout> <rectangle x="172.00" y="70.00" width="40.00" height="24.00"/> <color foreground="0,0,0" background="255,231,100"/> <font name="SansSerif" style="1" size="12" /> </layout> </relation> <relation id="401e8946:15209f3d481:-7faa" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Mother Of Child</label> </type> <layout> <rectangle x="317.00" y="310.00" width="40.00" height="24.00"/> <color foreground="0,0,0" background="255,231,100"/> <font name="SansSerif" style="1" size="12" /> </layout> </relation> <relation id="401e8946:15209f3d481:-7fa0" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Gender Of Child</label> </type> <layout> <rectangle x="278.00" y="270.00" width="40.00" height="24.00"/> <color foreground="0,0,0" background="255,231,100"/> <font name="SansSerif" style="1" size="12" /> </layout> </relation> <relation id="401e8946:15209f3d481:-7fc5" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Gender of Adult</label> </type> <layout> <rectangle x="79.00" y="218.00" width="40.00" height="24.00"/> <color foreground="0,0,0" background="255,231,100"/> <font name="SansSerif" style="1" size="12" /> </layout> </relation> <concept id="401e8946:15209f3d481:-7fd4" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Girl</label> </type> <layout> <rectangle x="92.00" y="298.00" width="40.00" height="30.00"/> <color foreground="255,255,255" background="0,94,192"/> <font name="SansSerif" style="1" size="12" /> </layout> </concept> <concept id="401e8946:15209f3d481:-7fd5" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Female</label> </type> <layout> <rectangle x="358.50" y="201.00" width="49.00" height="30.00"/> <color foreground="255,255,255" background="0,94,192"/> <font name="SansSerif" style="1" size="12" /> </layout> </concept> <concept id="401e8946:15209f3d481:-7fb3" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Woman</label> </type> <layout> <rectangle x="148.00" y="262.00" width="52.00" height="30.00"/> <color foreground="255,255,255" background="0,94,192"/> <font name="SansSerif" style="1" size="12" /> </layout> </concept> <concept id="401e8946:15209f3d481:-7fd6" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Adult</label> </type> <layout> <rectangle x="162.00" y="129.00" width="40.00" height="30.00"/> <color foreground="255,255,255" background="0,94,192"/> <font name="SansSerif" style="1" size="12" /> </layout> </concept> <concept id="401e8946:15209f3d481:-7fd7" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Child</label> </type> <layout> <rectangle x="37.00" y="148.00" width="40.00" height="30.00"/> <color foreground="255,255,255" background="0,94,192"/> <font name="SansSerif" style="1" size="12" /> </layout> </concept> <concept id="401e8946:15209f3d481:-7fd8" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Human</label> </type> <layout> <rectangle x="181.00" y="11.00" width="48.00" height="30.00"/> <color foreground="255,255,255" background="0,94,192"/> <font name="SansSerif" style="1" size="12" /> </layout> </concept> <arrow id="401e8946:15209f3d481:-7f96" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7f98" to="401e8946:15209f3d481:-7fbb"> <layout> <rectangle x="396.48" y="128.66" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fca" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fcc" to="401e8946:15209f3d481:-7fd8"> <layout> <rectangle x="193.77" y="53.12" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7f97" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7f9b" to="401e8946:15209f3d481:-7f98"> <layout> <rectangle x="314.23" y="169.88" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fcb" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fd6" to="401e8946:15209f3d481:-7fcc"> <layout> <rectangle x="183.48" y="106.05" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7f99" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7f9c" to="401e8946:15209f3d481:-7fd6"> <layout> <rectangle x="207.00" y="160.54" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fab" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fb0" to="401e8946:15209f3d481:-7fd8"> <layout> <rectangle x="274.59" y="47.60" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fac" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fbb" to="401e8946:15209f3d481:-7fb0"> <layout> <rectangle x="384.85" y="99.96" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fad" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fb2" to="401e8946:15209f3d481:-7fd8"> <layout> <rectangle x="235.08" y="53.19" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fae" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fd5" to="401e8946:15209f3d481:-7fb2"> <layout> <rectangle x="316.05" y="140.06" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fc2" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fc5" to="401e8946:15209f3d481:-7fd7"> <layout> <rectangle x="76.19" y="195.99" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fc3" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fd4" to="401e8946:15209f3d481:-7fc5"> <layout> <rectangle x="101.07" y="264.73" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fa1" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fa3" to="401e8946:15209f3d481:-7fd6"> <layout> <rectangle x="165.23" y="172.76" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fa2" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fb3" to="401e8946:15209f3d481:-7fa3"> <layout> <rectangle x="161.91" y="233.11" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fa4" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fa7" to="401e8946:15209f3d481:-7fbb"> <layout> <rectangle x="414.30" y="251.12" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fc7" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fc9" to="401e8946:15209f3d481:-7fd6"> <layout> <rectangle x="140.08" y="113.96" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fa5" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fc1" to="401e8946:15209f3d481:-7fa7"> <layout> <rectangle x="224.84" y="350.58" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fc8" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fd7" to="401e8946:15209f3d481:-7fc9"> <layout> <rectangle x="85.27" y="122.84" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fa8" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7faa" to="401e8946:15209f3d481:-7fd5"> <layout> <rectangle x="354.68" y="268.04" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fa9" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fd4" to="401e8946:15209f3d481:-7faa"> <layout> <rectangle x="222.14" y="313.57" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fbc" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fbf" to="401e8946:15209f3d481:-7fd7"> <layout> <rectangle x="49.28" y="211.56" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fbd" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fc1" to="401e8946:15209f3d481:-7fbf"> <layout> <rectangle x="51.13" y="296.73" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7f9a" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7f9b" to="401e8946:15209f3d481:-7f9c"> <layout> <rectangle x="242.69" y="195.83" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7f9d" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fa0" to="401e8946:15209f3d481:-7fd5"> <layout> <rectangle x="330.90" y="249.35" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7f9e" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fb3" to="401e8946:15209f3d481:-7fa0"> <layout> <rectangle x="236.58" y="275.68" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fb4" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fb7" to="401e8946:15209f3d481:-7fd8"> <layout> <rectangle x="131.39" y="43.42" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fb5" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fd7" to="401e8946:15209f3d481:-7fb7"> <layout> <rectangle x="62.59" y="107.31" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> </graph> </conceptualgraph>
My table looks like this. $name is the xml file.
<?php error_reporting(0); $name = $_FILES['file']['name']; $extension = strtolower(substr($name, strpos($name, '.')+1)); $tmp_name = $files['file']['tmp_name']; if(isset($name)){ if(!empty($name)){ if(($extension == 'cogxml' || $extension=='cgx')){ $location = 'uploads/'; if(move_uploaded_file($tmp_name, $location.$name)){ echo 'uploaded'; }else{ echo 'There Was an error'; } }else { echo 'File must be cogxml or cgx'; } } } ?> <html> <head> <title>CharGer and CoGui</title> <link rel="stylesheet" type="text/css" href="mystyle.css"/> </head> <body> <form action="test8.php" method="post" enctype="multipart/form-data"> <input type="file" name="file"><br> <input type="submit" value="Submit"> </form> <table border="1"> <tr> <th>width="5%">Concept Name</th> <th width="5%">Relation Type</th> <th width="44%">CoGui XML</th> <th width="46%">CharGer XML</th> </tr> <tr> <td></td> <td></td> <td> <?php $xml = new DOMDocument('1.0', 'UTF-8'); $xml->formatOutput = true; $xml->preserveWhiteSpace = false; $xml->load($name); $xsl = new DOMDocument; $xsl->load('CoGui.xsl'); // Configure transformer $proc = new XSLTProcessor; $proc->importStyleSheet($xsl); // Transform XML source $newXML = new DOMDocument; $newXML = $proc->transformToXML($xml); ?> <xmp><?php echo $newXML;?> </xmp> <?php // Save output to file $xmlfile = 'Output.xml'; file_put_contents($xmlfile, $newXML); ?> </td> <td> <?php $xmls = new DOMDocument('1.0', 'UTF-8'); $xmls->formatOutput = true; $xmls->preserveWhiteSpace = false; $xmls->load($name); $xsls = new DOMDocument; $xsls->load('CharGer.xsl'); // Configure transformer $procs = new XSLTProcessor; $procs->importStyleSheet($xsls); // Transform XML source $newXMLs = new DOMDocument; $newXMLs = $procs->transformToXML($xmls); ?> <xmp> <?php echo $newXMLs;?> </xmp> <?php $xmlfiles = 'Output2.xml'; file_put_contents($xmlfiles, $newXMLs); ?> </td> </tr> </table </body> </html>
No comments:
Post a Comment