Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial xsl:record #1858

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open

Initial xsl:record #1858

wants to merge 43 commits into from

Conversation

johnlumley
Copy link
Contributor

An initial draft of the xsl:record instruction, for discussion

@johnlumley
Copy link
Contributor Author

johnlumley commented Mar 4, 2025

The proposed signature uses @xsl:on-duplicates but duplicate handling within the xsl:map should now use @duplicates so the signature needs to be altered. In addition a change to accommodate @xsl:duplicates in the Handling of duplicate keys section needs adding.

ndw and others added 10 commits March 4, 2025 17:10
…rdered-maps

1771 Add option for deep-equal to consider map order
Reduce the indentation in the ToC
Relax the return type of the Invisible XML parsing function
1820 Attempt to add change markup in collapsed ToC
…text-item

1845 Revised design of methods to use . rather than $this
@michaelhkay
Copy link
Contributor

I suggest putting xsl:record under a separate section heading from xsl:map, it makes it easier to find the rules applying to each instruction.

There's a need to change the rules for standard attributes such as [xsl:]version -- we can no longer simply say that if the element is in the XSLT namespace, the attribute isn't, and vice versa.

Otherwise looks good.

@michaelhkay michaelhkay added XSLT An issue related to XSLT Feature A change that introduces a new feature labels Mar 6, 2025
@michaelhkay michaelhkay added the Tests Needed Tests need to be written or merged label Mar 6, 2025
@michaelhkay
Copy link
Contributor

Needs extensions to the schema for XSLT 4.0.

@ndw
Copy link
Contributor

ndw commented Mar 10, 2025

I can see the motivation for xsl:as and xsl:duplicates, but that's so different from the other instructions that I fear it will cause confusion. I think users are at least as likely to write <xsl:record as="..." to define the record type as they are to write <xsl:record as="..." meaning they want to create an entry with a key of as.

I think I'd prefer it if we just reserved the names as and duplicates for ourselves and said you have to use a sequence constructor to make those entries, if you need them.

@michaelhkay
Copy link
Contributor

so different from the other instructions

Yes, I share this concern. The design is very logical, but also rather unfamiliar. However, I'm not comfortable with reserving attribute names either.

Perhaps an alternative is to put the attributes on a separate element, xsl:record-options, appearing as a child of xsl:record?

@johnlumley
Copy link
Contributor Author

Yes, I share this concern. The design is very logical, but also rather unfamiliar. However, I'm not comfortable with reserving attribute names either.

I agree - we have a bit of a quandary, with no obvious single-element + options attributes + entry attributes solution possible .

Perhaps an alternative is to put the attributes on a separate element, xsl:record-options, appearing as a child of xsl:record?

This might be a possibility if it only applies to the as|duplicates attributes, which is what I think you're suggesting, but if all entry-generating attributes have to go on an xsl:record-options child (which I suspect you're not advocating) it sort of minimises the conciseness goal. And now we have a special instruction where the options declaration is in a non-intuitive and anomalous position.

Interestingly, in the absence of a contained sequence constructor (which probably will be the vast majority of use cases) we don't need the @duplicates option as there can be no key duplication, so it's only needed where there is a sequence constructor, which already reduces the conciseness.

michaelhkay and others added 3 commits March 10, 2025 16:19
…ates-in-maps

1725b Further elaboration of duplicates handling in maps
…ions_filtered_by_type

1456 Lookup expressions filtered by type
@ndw
Copy link
Contributor

ndw commented Mar 13, 2025

Is there a compelling reason not to allow QName keys:

<xsl:record xmlns:e="http://example.com" e:foo="Spoon!"/>

@michaelhkay
Copy link
Contributor

Is there a compelling reason not to allow QName keys:

Mainly consistency with record type declarations. You can't define a record type that expects non-string keys. That in turn is consistent with JSON objects.

@ndw
Copy link
Contributor

ndw commented Mar 13, 2025

#HEADDESK, of course. Apologies for the noise, I was thinking of a map constructor.

Added section; corected XSLT source transformation code.
Restrictions on standard attributes, change to type-checking wording, addition of streamability
@johnlumley johnlumley requested a review from ndw as a code owner March 17, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature A change that introduces a new feature Tests Needed Tests need to be written or merged XSLT An issue related to XSLT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants