Subject: Re: [xsl] Process map entries in defined order From: "Michael Mueller-Hillebrand michael.mueller-hillebrand@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 1 Jul 2025 05:27:43 -0000 |
Hi Gerrit, How should I know what I thought of last year...? It was interesting to follow the discussion... and thanks a lot for the suggestion of using an XML document, I can just keep those <substitute elements>. That is obviously what I would have chosen with XPath 2.0. Best regards, Michael -----Original Message----- From: Imsieke, Gerrit, le-tex gerrit.imsieke@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Sent: Monday, June 30, 2025 10:02 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Process map entries in defined order Caution: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. Did you raise this before? [1] In XPath 4.0, maps are ordered by default. [2] BaseX has already rolled out sorted maps, I donC"BBt know when Saxon will follow. In the meantime, maybe use an XML document instead of maps? Gerrit [1] https://github.com/qt4cg/qtspecs/issues/564 [2] https://qt4cg.org/specifications/xpath-datamodel-40/Overview.html#map-items On 30.06.2025 08:58, Michael Mueller-Hillebrand michael.mueller-hillebrand@xxxxxxxxx wrote: > Dear all, > > I have a scenario with a user-defined set of substitutions which should be applied to text nodes (a.k.a. strings). The XML is built like this: > > <substitute search="car" replace="auto"/> > <substitute search="auto" replace="mobile"/> > > As you can see from this little example the order of replacements is > important. I started with creating a map(xs:string, xs:string) for the > search and replace terms. Recursively applying the substitutions uses > map:keys($subs). Next, I learned from the specification that this > function "Returns the set of keys found in an input map, in > arbitrary order." > > Since I want to honor the order given by the user, I think the only way out is to change my map to include an integer key and feature the search and replace string as the entry value: map(xs:integer, xs:string+) and always sort the list of keys by number. > > Or is there another smoother way handling this challenge? > > Best regards, > > Michael
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Thread | [xsl] XSL-List Guidelines, B Tommie Usdin btusd | |
Date | [xsl] XSL-List Guidelines, B Tommie Usdin btusd | |
Month |