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

Re: Using xsl:value-of select in a form input textbox

Subject: Re: Using xsl:value-of select in a form input textbox
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 11 Mar 2004 18:25:43 -0500
input textbox
Hi Anne,

At 05:27 PM 3/11/2004, you wrote:
Hi,

I am new to XSLT and am trying to parse an XML string containing a phone
number into 3 strings - the area, prefix, and suffix.  (This XML string is
coming from a database.)  I want to display the substrings in separate
textboxes.   Here is what I have so far:

<!-- THIS CURRENTLY PUTS THE ENTIRE EVENINGPHONE IN THE TEXTBOX -->
<!-- WHICH I DO NOT WANT -->
<input type="text" name="txtHPhone" size="20" maxlength="10"
value="{UPDATEADDRESS/RECEIVER/ADDRESS/EVENINGPHONE}" />

This uses an Attribute Value Template (the brackets) to tell the processor to interpret the string inside as XPath, and evaluate it.


You can do exactly this but also include the substringing operations you are already doing elsewhere:

<!-- THIS SUCCESSFULLY DISPLAYS THE AREA  OF EVENINGPHONE -->
<xsl:value-of
select="substring(UPDATEADDRESS/RECEIVER/ADDRESS/EVENINGPHONE,1,3)" />

so ...


<!-- INSTEAD, WHAT value WOULD GO IN HERE: -->
<input type="text" name="txtHPhoneAREA" size="20" maxlength="10" value="" />

...you would try


<input type="text" name="txtHPhoneAREA" size="20" maxlength="10"
  value="{substring(UPDATEADDRESS/RECEIVER/ADDRESS/EVENINGPHONE,1,3)}" />

...although the code would be cleaner if you could contrive it in such a way that the EVENINGPHONE node you are after were the context node of the expression. (You could do this by emitting the result <input> node inside a template matching the EVENINGPHONE, for example.) In that case the result element in your stylesheet would look something like:

<input type="text" name="txtHPhoneAREA" size="20" maxlength="10"
  value="{substring(.,1,3)}" />

...because the XPath '.' (short for 'self::node()') would then refer to the EVENINGPHONE itself.

I hope that helps. Ask again for any clarifications.

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================


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.