Jump to content
cpdev

XML data is omitted

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...