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

How to sort based on the number of child elements?

Subject: How to sort based on the number of child elements?
From: "Roger L Costello costello@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 9 May 2022 17:31:40 -0000
 How to sort based on the number of child elements?
Hi Folks,

I have an XML Schema that contains a xs:choice. I want to sort the branches of
the choice, in longest-to-shortest order.

Here is a xs:choice with two branches:

<xs:choice>
    <xs:element name="MilitaryDayTime">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Day" type="xs:string"/>
                <xs:element name="HourTime" type="xs:string"/>
                <xs:element name="MinuteTime" type="xs:string"/>
                <xs:element name="TimeZone" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="DateTimeGroup">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Day" type="xs:string"/>
                <xs:element name="HourTime" type="xs:string"/>
                <xs:element name="MinuteTime" type="xs:string"/>
                <xs:element name="TimeZone" type="xs:string"/>
                <xs:element name="MonthName" type="xs:string"/>
                <xs:element name="Year" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:choice>

The first branch is an element with 4 child elements. The second branch is an
element with 6 child elements. So sorting the branches longest-to-shortest
will result in reversing the order of the branches.

I cannot use xsl:sort for this, right?

Is there an easy solution to this task?

/Roger

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.