[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Include States

Subject: RE: Include States
From: "Martinez, Brian" <brian.martinez@xxxxxxxxxxx>
Date: Wed, 16 Apr 2003 09:47:26 -0600
states.xml
> From: Karl J. Stubsjoen [mailto:karl@xxxxxxxxxxxxx]
> Sent: Wednesday, April 16, 2003 9:26 AM
> Subject:  Include States
> 
> 
> Hello,
> I know how to import a stylesheet into my stylesheet.  What I 
> need to do is
> import XML into my style sheet.
> The XML is a list of states, full text and abbreviation.
> Actually, If I could import a stylesheet responsible for 
> trnasforming the
> state xml file into an HTML select widget, this would be 
> good.  But, can
> that stylesheet then import the XML?

Use the document() function.

Example XML:

<states>
  <state abbr="AL">Alabama</state>
  <state abbr="AR">Arkansas</state>
  <!-- etc. -->
</states>

XSLT (not meant to be standalone output):

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html"/>

  <xsl:variable name="state-xml" select="document('states.xml')/states"/>  

  <xsl:template match="/">
    <select name="states-dropdown">
      <xsl:for-each select="$state-xml/state">
        <option value="{@abbr}"><xsl:value-of select="."/></option>
      </xsl:for-each>
    </select>
  </xsl:template>
</xsl:stylesheet>

Output:

<select name="states-dropdown">
  <option value="AL">Alabama</option>
  <option value="AR">Arkansas</option>
</select>

hth,
b.

| brian martinez                           brian.martinez@xxxxxxxxxxx |
| lead gui programmer                                    303.708.7248 |
| cheap tickets, part of trip network                fax 303.790.9350 |
| 6436 s. racine cir.                             englewood, co 80111 |
| cendant travel distribution services   http://www.cheaptickets.com/ |

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.