This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Include problem...


I have an include question.

I'm building a Web application that has many forms.  More than one of the
forms requires pulldown menus with similar data such as a State menu on a
customer form.  I want to be able to use centrally located State menu XML
and XSL documents that are transformed and included in any other XSL
document.

My question is: is it possible to include and transform a state menu XML
document with a state menu XSL file and include the result into the customer
XSL and then any other XSL document?

An example of all the documents are below.

Any help is appreciated.

Thanks,

King Wilder
king@gizmobeach.com


This example is transformed via ASP.

===========================================
Customer information
===========================================

This is the Customer XML snippet.
Filename: customer.xml

<Customer>
	<FirstName>John</FirstName>
	<LastName>Smith</LastName>
	...
	<Address>123 Fourth St.</Address>
	<City>Los Angeles</City>
	<State>CA</State>
</Customer>

This is the Customer XSL.
Filename: customer.xsl

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:template match="/">
		<form name="myForm">
			First name:
			<xsl:element name="input">
				<xsl:attribute name="name">firstname</xsl:attribute>
				<xsl:attribute name="value">
					<xsl:value-of select="//FirstName"/>
				</xsl:attribute>
			</xsl:element>
			<br/>
			Last name:
			<xsl:element name="input">
				<xsl:attribute name="name">lastname</xsl:attribute>
				<xsl:attribute name="value">
					<xsl:value-of select="//Lastname"/>
				</xsl:attribute>
			</xsl:element>
			<br/>
			...
			State:

			<!-- ++++++++++++++++++++++++ -->
			<!-- How do I include the transformed state XML document here? -->
			<!-- Please show an example.  I know about document() and include,
but -->
			<!-- I don't know how they are implemented here.  Thanks. -->
			<!-- ++++++++++++++++++++++++ -->



		</form>
	</xsl:template>
</xsl:stylesheet>

===========================================
End Customer information
===========================================

===========================================
Begin State menu info
===========================================

This is the State menu XSL.
Filename: statemenu.xsl

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
	<xsl:call-template name="statecombo"></xsl:call-template>
</xsl:template>

	<xsl:template name="statecombo">
		<xsl:param name="selected-option-value">@value</xsl:param>
		<xsl:param name="control-name">state</xsl:param>
		<select size="1">
			<xsl:attribute name="name"><xsl:value-of
select="$control-name"/></xsl:attribute>
			<xsl:for-each select="/statemenu/option">
				<option>
					<xsl:attribute name="value"><xsl:value-of
select="@value"/></xsl:attribute>
					<xsl:if test="@value = $selected-option-value">
						<xsl:attribute name="selected">yes</xsl:attribute>
					</xsl:if>
					<xsl:value-of select="@description"/>
				</option>
			</xsl:for-each>
		</select>
	</xsl:template>

</xsl:stylesheet>



This is the State menu XML snippet.
Filename: statemenu.xml

<statemenu name="state" id="state">
<option value="AL" description="Alabama" />
<option value="AK" description="Alaska" />
<option value="AB" description="Alberta" />
<option value="AZ" description="Arizona" />
...
<option value="YT" description="Yukon" />
</statemenu>

===========================================
End State menu info
===========================================

King Wilder
-------------
Gizmo Beach
king@gizmobeach.com
www.gizmobeach.com
626 351-4334
-------------


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]