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

Re: Copying and transforming/Recursion?

Subject: Re: Copying and transforming/Recursion?
From: "John E. Simpson" <simpson@xxxxxxxxxxx>
Date: Tue, 10 Oct 2000 16:45:41 -0400
Re: Copying and transforming/Recursion?
At 02:45 PM 10/10/2000 -0400, Jeff Saylor wrote:
Starting with:

  <xml>
    <submittedValues>
      <submittedValue fieldname='title'>mr.</submittedValue>
    </submittedValues>

    <display>
      <p>
        title:<input type='text' fieldname='title' value=''/>
      </p>
    </display>
  </xml>

Effectively, I want to use the <submittedValue>'s text with the matching (by
@fieldname) <display>'s <input> to get:

  <display>
    <p>
      title:<input type='text' fieldname='title' value='mr.' />
    </p>
  </display>

Well, it's hard to generalize from a small XML doc. But if all your submittedValues and display elements follow this regular pattern, this should work:


<xsl:template match="xml_root">
<xsl:for-each select="submittedValues/submittedValue">
<xsl:if test="./@fieldname=../following-sibling::*//input/@fieldname">
<display>
<p>title:
<input type="text" fieldname="{@fieldname}">
<xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
</input>
</p>
</display>
</xsl:if>
</xsl:for-each>
</xsl:template>


(Btw, I changed the name of your root "xml" element to "xml_root." I didn't know if you really meant for an element to be called "xml" but if so, it offended what few purist sensibilities I still have. :)

Looks okay in IE5 (Sept. '00 release), and Saxon outputs:

<display>
    <p>title:
        <input type="text" fieldname="title" value="mr.">
    </p>
</display>

this involves outputting the <display> tag, and its contents, while
selectively transforming an element within them - I can not figure out a way
to do this.  I am thinking copy-of and recursive templates would do the
trick, but I can't get a grasp on how to do it...

Sorry, I didn't use copy-of or recursive templates!


===============================================================
John E. Simpson | "He asked me if I knew what
http://www.flixml.org | time it was. I said, 'Yes, but
XML Q&A: http://www.xml.com | not right now.'" (Steven Wright)



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.