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

Re: XPath expression to express: There must be an empt

Subject: Re: XPath expression to express: There must be an empty sequence
From: "Christoph Naber pentium120mhz@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 19 Nov 2017 19:47:59 -0000
Re:  XPath expression to express: There must be an empt
Hello Roger,

I understand - taking your last question into account where you wanted to generate the sequences - that you want the XSLT rules to verify, if some set of sequences is a solution for the combinatorical problem:

For the set S with m elements list the n-tuples for n := [0, m]
(https://en.wikipedia.org/wiki/Permutation#Permutations_with_repetition)

The total number of "permutations with repetition" according to this requirement will be
sum(m^k) for k := 0 to m and m := count(element)


Hopefully the mathematical background helps you tackling the problem...

One straight solution based on this mathematical fact would be to check whether the are
"sum(m^k) for k := 0 to m and m := count(element)" different sequences.


Best regards
Christoph Naber


Am 19.11.2017 um 19:38 schrieb Costello, Roger L. costello@xxxxxxxxx:
Hi Folks,

I have a set:

<set>
     <element>A</element>
     <element>B</element>
</set>

Here are some sequences derived from the set:

<sequences>
     <sequence/>
     <sequence>
         <item>A</item>
     </sequence>
     <sequence>
         <item>B</item>
     </sequence>
     <sequence>
         <item>A</item>
         <item>A</item>
     </sequence>
     <sequence>
         <item>A</item>
         <item>B</item>
     </sequence>
     <sequence>
         <item>B</item>
         <item>A</item>
     </sequence>
     <sequence>
         <item>B</item>
         <item>B</item>
     </sequence>
</sequences>

Notice that:
- there is an empty sequence
- there is a sequence corresponding to each element of the set
- and there are other sequences (that I'm not concerned with for now)

I want to create XPath expressions which express the rules that sequences must satisfy to be valid.

First rule: There must be an empty sequence. I expressed that rule with this XPath expression:

sequence[not(item)]

Assume that the root element, <sequences>, is the context node.

Is that the right way to express the rule? Is there a better XPath expression? By "better" I mean simpler, plainer, more transparent. I seek simplicity and clarity over efficiency and cleverness.

Second rule: There must be a singleton sequence corresponding to every element in the set. A "singleton sequence" is a <sequence> containing one <item>.

I expressed that rule with this XPath expression:

every $element in $set//element satisfies exists(sequence[(item = $element) and not(item[2])])

Assume that $set is a variable whose value is the set.

Is that the right way to express the rule? Is there a better XPath expression?

/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.