Jump to content

XML data is omitted


cpdev

Recommended Posts

Hello Guys,

 

I'm relatively new to XSLT and obviously I miss the wood for trees....

 

here is the XML I want to send to the Transformator (php simple_xml):

<?xml version='1.0' standalone='yes'?>	<master>	 <customer>            <name>TEstkunde</name>            <short>TK</short>            <ref>0001</ref>         </customer>	 <customer>            <name>TEstkunde2</name>            <short>TK2</short>           <ref>0002</ref>        </customer>   </master>

and here the XSL Stylesheet I copied and manipulated from W3 schools "XSL:For-each":

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">  <table>    <tr>       <th>Kurzname</th>       <th>Kundenname</th>       <th>Kundenreferenznummer</th>       <th>aktive Projekte</th>    </tr>    <xsl:for-each select="customer">	<tr>	<td><xsl:value-of select="name" /></td>	<td><xsl:value-of select="short" /></td>	<td><xsl:value-of select="ref" /></td>        <td><xsl:value-of select="proj" /></td>        </tr>    </xsl:for-each>    <tr>	<td><input type="text" caption="Kundenname" id="customer"/></td>	<td><input type="text" caption="Kurzname" id="cust_short"/></td>	<td><input type="text" caption="Kundenerferenznummer" id="cust_id" /></td>	<td><input type="submit" value="+" /></td>    </tr></table></xsl:template></xsl:stylesheet>

For whatever reason, only the last row and the header is shown, but the data from the XML is omitted.

 

Can you please point me in the right direction and possibly explain where I'm wrong?

 

Thanks a lot.

 

BR,

Sebastian

Link to comment
Share on other sites

Going by this W3Schools example I think maybe including the root node in the selector might work:

<xsl:for-each select="master/customer">

 

It's been years since I last used XSLT, so I'm not sure. And it might be that the PHP library works a little bit different than browsers do. Unfortunately, our resident XML expert hasn't been on the forums for a couple of years.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...