I'm trying to make my life easier. This is something which invariables
leaves it more complicated. Anyway, our web stores run off an XSLT / XML
engine in PHP. It works well, but coding each of tables I needed for
different data types (users, configurations, etc., etc.) was a mess... so
I'm trying to abstract all that. The XML and XSLT for one thing I've already
got working is below.
My question is this: I now want to create a template that looks at the data
types, creates a row for displaying such data, and displays it all. But that
would require loops running through seperate nodes and I totally don't
understand how to do that. Any comments about or help with the idea or the
implementation would be appreciated.
Johnathon
<web_document>
<web_store>
<store_name>Test Site</store_name>
<domain>testsite.com</domain>
<checkout_url>http://www.testsite.com/</checkout_url>
</web_store>
<template>
<public_template_name>test</public_template_name>
<seller_template_name>llf</seller_template_name>
</template>
<environmental_variables>
<short_date>2006-01-31</short_date>
<long_date>Tuesday, January 31st, 2006</long_date>
<year>2006</year>
<visitor_session_id>27q6pucofq09dnej48kt2sd1q5</visitor_session_id>
<cart_id></cart_id>
</environmental_variables>
<request>
<display>manage</display>
<display_type>user</display_type>
<display_format>formatted_xml</display_format>
<PHPSESSID>27q6pucofq09dnej48kt2sd1q5</PHPSESSID>
</request>
<form_template>
<form_name>Add User</form_name>
<description>Please be certain about the type of user you are creating.
Also, be aware that adding a duplicate customer will cause an unsightly
error.</description>
<submit_details>
<display>manage</display>
<display_format>seller</display_format>
<display_type>user</display_type>
<action>add</action>
<action_type_a>user</action_type_a>
</submit_details>
<define_field>
<field_name>first_name</field_name>
<field_name_formatted>First Name</field_name_formatted>
<field_type>text</field_type>
<max_length>100</max_length>
</define_field>
<define_field>
<field_name>last_name</field_name>
<field_name_formatted>Last Name</field_name_formatted>
<field_type>text</field_type>
<max_length>40</max_length>
</define_field>
<define_field>
<field_name>username</field_name>
<field_name_formatted>e-mail
Address</field_name_formatted>
<field_type>text</field_type>
<max_length>100</max_length>
</define_field>
<define_field>
<field_name>password</field_name>
<field_name_formatted>Password</field_name_formatted>
<field_type>password</field_type>
<max_length>40</max_length>
</define_field>
<define_field>
<field_name>seller_id</field_name>
<field_name_formatted>Seller</field_name_formatted>
<field_type>select</field_type>
<options>
<option>
<name>a Smarter Buy</name>
<value>1</value>
</option>
</options>
</define_field>
<define_field>
<field_name>user_type</field_name>
<field_name_formatted>User Type</field_name_formatted>
<field_type>select</field_type>
<options>
<option>
<name>Customer</name>
<value>8</value>
</option>
<option>
<name>Seller</name>
<value>16</value>
</option>
<option>
<name>Administrator</name>
<value>32</value>
</option>
</options>
</define_field>
<define_field>
<field_name>opt_in</field_name>
<field_name_formatted>Mailing
List</field_name_formatted>
<field_type>select</field_type>
<options>
<option>
<name>Yes - Receive all bulk
emails</name>
<value>1</value>
</option>
<option>
<name>No - Do not received bulk
emails</name>
<value>0</value>
</option>
</options>
</define_field>
<data_set> <data>
<username>jw(_at_)llfitness(_dot_)com</username>
<first_name>Johnathon</first_name>
<last_name>Wright</last_name>
<user_type>032</user_type>
<last_login>2006-01-31 10:43:32</last_login>
<opt_in>0</opt_in>
</data> <data>
<username>lacy(_at_)llfitness(_dot_)com</username>
<first_name>Lacy</first_name>
<last_name>Tylock</last_name>
<user_type>032</user_type>
<last_login>2006-01-25 15:59:16</last_login>
<opt_in>0</opt_in>
</data> <data>
<username>brian(_at_)llfitness(_dot_)com</username>
<first_name>Brian Leleux</first_name>
<last_name></last_name>
<user_type>008</user_type>
<last_login>0000-00-00 00:00:00</last_login>
<opt_in>1</opt_in>
</data> <data>
<username>leslie(_at_)crazyredheadart(_dot_)com</username>
<first_name>Leslie</first_name>
<last_name>Leonpacher</last_name>
<user_type>016</user_type>
<last_login>0000-00-00 00:00:00</last_login>
<opt_in>0</opt_in>
</data> <data>
<username>derek(_at_)llfitness(_dot_)com</username>
<first_name>Derek</first_name>
<last_name>Hernandez</last_name>
<user_type>000</user_type>
<last_login>0000-00-00 00:00:00</last_login>
<opt_in>1</opt_in>
</data> <data>
<username>kelly(_at_)llfitness(_dot_)com</username>
<first_name>Kelly</first_name>
<last_name>Fowler</last_name>
<user_type>016</user_type>
<last_login>0000-00-00 00:00:00</last_login>
<opt_in>1</opt_in>
</data> </data_set> </form_template>
</web_document>XSLT for the ADD DATA form, which is called by another
template, user/add.xslt (which explains why the template isn't
web_document):<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template
match="form_template"><link href="/seller_templates/generic/basic.css"
rel="stylesheet" type="text/css" /><div
class="Main_Container"><h1><xsl:value-of select="form_name"
/></h1><p><xsl:value-of select="description" /></p><form action="/"
method="post"><input type="hidden" name="display"
value="{submit_details/display}" /><input type="hidden"
name="display_format" value="{submit_details/display_format}" /><input
type="hidden" name="display_type" value="{submit_details/display_type}"
/><input type="hidden" name="action" value="{submit_details/action}"
/><input type="hidden" name="action_type_a"
value="{submit_details/action_type_a}" /><input type="hidden"
name="action_id_a1" value="{submit_details/action_id_a1}" /><input
type="hidden" name="action_id_a2" value="{submit_details/action_id_a2}"
/><xsl:if test="action_type_b"><input type="hidden" name="action_type_b"
value="{submit_details/action_type_b}" /></xsl:if><xsl:if
test="action_id_b1"><input type="hidden" name="action_id_b1"
value="{submit_details/action_id_b1}" /></xsl:if><xsl:if
test="action_id_b2"><input type="hidden" name="action_id_b2"
value="{submit_details/action_id_b2}" /></xsl:if><table width="500"
border="0" align="center" cellpadding="4" cellspacing="1"><xsl:for-each
select="define_field"> <xsl:choose> <xsl:when test="field_type = 'text'">
<tr> <td align="right"><xsl:value-of select="field_name_formatted"
/></td> <td align="left"><input type="text" name="{field_name}"
value="{value}" /></td> </tr> </xsl:when> <xsl:when
test="field_type = 'password'"> <tr> <td align="right"><xsl:value-of
select="field_name_formatted" /></td> <td align="left"><input
type="password" name="{field_name}" /></td> </tr> </xsl:when>
<xsl:when test="field_type = 'select'"> <tr> <td
align="right"><xsl:value-of select="field_name_formatted" /></td> <td
align="left"> <select name="{field_name}"> <xsl:for-each
select="options/option"> <option value="{value}"> <xsl:if
test="selected"> <xsl:attribute name="selected">TRUE</xsl:attribute>
</xsl:if> <xsl:value-of select="name" /> </option>
</xsl:for-each> </select> </td> </tr> </xsl:when> <!-- SELECT
BOX --> </xsl:choose></xsl:for-each> <tr> <td> </td> <td> <input
type="submit" name="Submit" /> <xsl:for-each select="define_field">
<xsl:if test="field_type = 'hidden'"> <input type="hidden"
name="{field_name}" value="{value}" /> </xsl:if> </xsl:for-each> </td>
</tr> </table></form></div><!-- main
container --></xsl:template></xsl:stylesheet>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--