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

Pairing elements according to attributes with XSLT 1

Subject: Pairing elements according to attributes with XSLT 1
From: Andy Kohn <andydev@xxxxxxxxx>
Date: Wed, 22 Jul 2009 16:52:01 +1000
 Pairing elements according to attributes with XSLT 1
Hi all,

I'm trying to pair elements according to attributes using XSLT 1.

Giving an example would be easier to explain ;)

This is an example of the input XML:


<KeywordsInfo>
    <KeywordsEntry>
        <keyword size="big">bowling ball</keyword>
        <keyword size="medium">should not be included</keyword>
        <keyword size="small">tennis ball</keyword>
        <keyword size="small">table tennis ball</keyword>
    </KeywordsEntry>
    <KeywordsEntry>
        <keyword size="big">mountain 1</keyword>
        <keyword size="big">mountain 2</keyword>
        <keyword size="small">chair 1</keyword>
        <keyword size="small">chair 2</keyword>
    </KeywordsEntry>
    <KeywordsEntry>
        <keyword size="medium">should not be excluded at all</keyword>
        <keyword size="tiny">should not be excluded at all</keyword>
    </KeywordsEntry>
</KeywordsInfo>


I need to create an XSLT 1, that gets two parameters, fromSize and
toSize, which then creates pairs of this entries.

For example, if I send fromSize=big, toSize=small, I need to get this result:


<MainWordInput xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="entriesResult.xsd"
            fromSize ="big"
            toSize="small">
   <Entries>
      <first>bowling ball</first>
      <second>tennis ball</second>
   </Entries>
   <Entries>
      <first>bowling ball</first>
      <second>table tennis ball</second>
   </Entries>
   <Entries>
      <first>mountain 1</first>
      <second>chair 1</second>
   </Entries>
   <Entries>
      <first>mountain 1</first>
      <second>chair 2</second>
   </Entries>
   <Entries>
      <first>mountain 2</first>
      <second>chair 1</second>
   </Entries>
   <Entries>
      <first>mountain 2</first>
      <second>chair 2</second>
   </Entries>
</MainWordInput>

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-2011 All Rights Reserved.