0

I know that there are really a mass of XML XSLT php merging threads at SO. But php specific i could not found what might my problem:

$xml = new DOMDocument;
$xml->load("f.xml");

$xsl = new DOMDocument; $xsl->load('test.xsl');

// init and configure processor $proc = new XSLTProcessor; $proc->importStyleSheet($xsl); // import xsl document $xml2=$proc->transformToXML($xml); echo $xml2;

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
<xsl:param name="owner" select="'Robert Kühn'"/>
<xsl:output method="xml" version="1.0" omit-xml-declaration="yes" indent="no"/> 
<xsl:strip-space elements="*"/>
</xsl:stylesheet>
and one xml file as example:
<?xml version="1.0" encoding="UTF-8"?>
<xPac>
<xyz id="15603"><varrDaten id="15604" zeit="1271099572" rechte="1">Daten<vbuch><vsyautor>Alertz, Ulrich</vsyautor><vsytitel>Vom Schiffbauhandwerk zur</vsytitel><vsybarcode>20560194</vsybarcode><vsystatus>S</vsystatus></vbuch><vbuch><vsyautor>Ridolfi, Carlo�[Hrsg.]�</vsyautor><vsytitel>Vite dei Tintoretto da le</vsytitel><vsybarcode>20014784</vsybarcode><vsystatus>S</vsystatus></vbuch><vbuch><vsyautor>Ridolfi, Carlo�[Hrsg.]�</vsyautor><vsytitel> life of Tintoretto and o</vsytitel><vsybarcode>20074791</vsybarcode><vsystatus>S</vsystatus></vbuch></varrDaten></xyz></xPac>
My xslt file looks a bit empty.. However i tried ´output method="xml"´. but it doesnot help.. the xml file is huge and i guess not so important

Question: PHP returns always the data as text or html but not in XML.. what i am doing wrong? I only want to edit the XML with xslt and save back to XML (file).

THanks for your help!

rokdd
  • 541
  • 4
  • 14
  • A sample XML and XSL file would be much more helpful. – Flavius Jun 16 '10 at 15:53
  • There is no question asked here. I VOTE to CLOSE. – Dimitre Novatchev Jun 16 '10 at 16:07
  • The xml file is nothing special (and huge) and i want that it works with every xml file. problems is more @xslt i guess so i posted. Question is simple: PHP shall return XML (or DOM nodes) but not a plaintext (without tags) – rokdd Jun 16 '10 at 16:20
  • So your question is: why are you getting plaintext and not XML when you do this? Please give us a stripped-down example XML file that exhibits this behavior. – Owen S. Jun 16 '10 at 16:49
  • Knowing that the XML input file is huge is irrelevant. Knowing whether it has matching nodes **is** important. Please provide an excerpt from the input file. But initially, based on a quick glance, it does appear that your XSL should select everything. – MJB Jun 16 '10 at 17:00
  • well it returns all (as i want) but in wrong format as i mentioned – rokdd Jun 16 '10 at 17:40
  • @rokdd: your question says "My xslt file looks a bit empty." Is that the wrong format you are talking about? Please provide more info. – MJB Jun 16 '10 at 19:10

1 Answers1

0

You wrote:

Question: PHP returns always the data as text or html but not in XML.. what i am doing wrong? I only want to edit the XML with xslt and save back to XML (file).

Answer: your stylesheet is copying every text node in document order. Then, in serialization fase, all result text nodes are merged into a single one. This behavior is from built-in templates. Your error is not to provide any template describing your desired result.