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

produce-xml-converter.xsl: XSpec tests and minor XSLT improvements #87

Merged

Conversation

galtm
Copy link
Collaborator

@galtm galtm commented Nov 20, 2023

Committer Notes

Closes #86

XSpec tests:

  • XSpec tests for produce-xml-converter.xsl in isolation
  • Stub of tests for produce-xml-converter.xsl from the context of produce-json-converter.xsl
  • Helper XSLT for use in XSpec tests
  • Sample definition maps to provide testing contexts

XSLT improvements:

  • Declare data types where known
  • Declare context item for named templates
  • Start XPath path from context instead of root, for testability

I ran the XSpec tests in Oxygen 26.0 and there are no failures.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you squashed any non-relevant commits and commit messages? [instructions]
  • Do all automated CI/CD checks pass?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you included examples of how to use your new feature(s)?
  • Have you updated all website and readme documentation affected by the changes you made? Changes to the website can be made in the website/content directory of your branch.

<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -->
<!-- produce-json-converter.xsl reaches these templates by name
instead of by match -->
<x:scenario label="Tests for name=make-template template" pending="TODO">
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO notations in this file are because I jotted down needs for future work. I anticipate that the work would be a separate pull request.

src/converter-gen/xml-to-json/produce-xml-converter.xsl Outdated Show resolved Hide resolved
src/converter-gen/xml-to-json/produce-xml-converter.xsl Outdated Show resolved Hide resolved
@@ -190,18 +199,19 @@
<xsl:call-template name="provide-namespace"/>
<xsl:apply-templates select="." mode="make-key-flag"/>
<xsl:apply-templates select="*" mode="make-pull"/>
<xsl:variable name="keyname" select="@_key-name"/>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this variable inside xsl:if because that's the only place where the variable is used

Comment on lines -265 to +281
<xsl:template priority="10" match="*[@scope = 'global'] | group[*/@scope = 'global']" mode="make-xml-match">
<xsl:template priority="10" match="*[@scope = 'global'] | group[*/@scope = 'global']" mode="make-xml-match"
as="text()">
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below this point, it looks like I changed a lot of lines. What I actually did was add @as attributes and wrap the template output in xsl:value-of. The reason for the latter is that when I considered the output data type of the template, it seemed simpler to consolidate multiple text nodes into a single text node.


<!-- A field without a GI is implicit in the XML; Metaschema prevents it from having flags -->
<xsl:template priority="2" match="field[empty(@gi)][(.|value)/@as-type='markup-multiline']" mode="make-xml-pull">
<!-- This template takes precedence over the one that matches field, unqualified
(even without priority=2 QUESTION: remove priority=2?) -->
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewers: Should I remove priority=2 or leave it as is?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, inclined to say leave as is, but maybe there's a reason to remove I am missing?

Copy link
Collaborator Author

@galtm galtm Jun 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the priority wasn't necessary, but I'm fine with leaving it. I pushed a new commit that removes the parenthetical part of the comment.

Comment on lines +996 to +998
<!-- QUESTION: The context is contrived and might not be the right way
to exercise the code in the situation where $parent-match contains
multiple match expressions. Does the context need fixing? -->
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewers: I wasn't sure about how to set up this scenario.

but no team members have recursive="true", so disambiguation
of 1st and 3rd items is not needed.
-->
<!-- QUESTION: Is it OK that they're not distinct? -->
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question for reviewers...

@galtm galtm changed the title XSpec tests and minor XSLT improvements produce-xml-converter.xsl: XSpec tests and minor XSLT improvements Nov 20, 2023
XSpec tests:
- XSpec tests for produce-xml-converter.xsl in isolation
- Stub of tests for produce-xml-converter.xsl from the
  context of produce-json-converter.xsl
- Helper XSLT for use in XSpec tests
- Sample definition maps to provide testing contexts

XSLT improvements:
- Declare data types where known
- Declare context item for named templates
- Start XPath path from context instead of root, for testability
@galtm galtm force-pushed the testing-produce-xml-converter branch from c2c751b to 9744dc8 Compare March 8, 2024 22:30
Copy link

github-actions bot commented Mar 8, 2024

XSpec Test Results

  2 files  ±0  40 suites  ±0   0s ⏱️ ±0s
105 tests ±0  90 ✅ ±0  15 💤 ±0  0 ❌ ±0 
114 runs  ±0  99 ✅ ±0  15 💤 ±0  0 ❌ ±0 

Results for commit 04f5159. ± Comparison against base commit 04a4a4c.

♻️ This comment has been updated with latest results.

@galtm
Copy link
Collaborator Author

galtm commented Mar 8, 2024

I rebased my commit off the develop branch and force-pushed, to refresh this pull request. The checks ran and all passed.

However, I don't think the new XSpec tests that are in this pull request are being picked up in the CI/CD testing.

@wendellpiez
Copy link
Collaborator

wendellpiez commented Jun 4, 2024

@galtm it is possible the configuration for XSpec runtimes here is skipping yours - we will have to look. Most likely there is a line to add in a Makefile or something similar.

What is your current sense? -- after merging the earlier two outstanding PRs I wonder if we should look at this together. The CI/CD doesn't actually have to run yet (in my view we can come back to that) but just in case there is something else. Apart from that question, how close is this to ready?

@galtm
Copy link
Collaborator Author

galtm commented Jun 5, 2024

Apart from that question, how close is this to ready?

There are two comments that contain the word "reviewers" or "Reviewers" and that haven't been resolved yet.

@galtm
Copy link
Collaborator Author

galtm commented Jun 5, 2024

What is your current sense? -- after merging the earlier two outstanding PRs I wonder if we should look at this together. The CI/CD doesn't actually have to run yet (in my view we can come back to that) but just in case there is something else.

Sure, we can look at it together next time we talk. Or, if you are inclined to merge this even before the CI/CD runs the new tests, I'm OK with that. If the CI/CD somehow picks up the new tests after the PR is merged, great; if not, one of us can create a GitHub issue so we won't forget to come back to this later.

@wendellpiez
Copy link
Collaborator

wendellpiez commented Jun 5, 2024

Another option maybe we should consider is merging this PR into develop, but into a common branch where we can test further, prior to the develop merge.

Indeed, such a staging branch might be a good place also to

And of course can work out remaining code/test issues there also.

As for xsl:template/@priority, I don't mind leaving them around when they make things more explicit. Of course comments make things more explicit as well.

Thanks Amanda!

@galtm
Copy link
Collaborator Author

galtm commented Jun 5, 2024

I have no opinions about branching approaches, so whatever you want to do is fine with me.

@wendellpiez
Copy link
Collaborator

So ... I made branch merge-June2024 as a place to pull things together.

Let's try pointing this PR there and seeing what trouble we get into. The merge branch is the same as develop right now so I expect no issues.

Then on that branch I can address #117 before merging into develop.

@wendellpiez wendellpiez changed the base branch from develop to merge-June2024 June 7, 2024 19:10
@wendellpiez wendellpiez marked this pull request as ready for review June 7, 2024 19:10
@wendellpiez wendellpiez requested a review from a team as a code owner June 7, 2024 19:10
@wendellpiez
Copy link
Collaborator

wendellpiez commented Jun 7, 2024

I'm merging this into a merge branch where the work can be reviewed before pushing up to develop.

Also will work on #117 in that branch.

@wendellpiez wendellpiez merged commit a0816ac into usnistgov:merge-June2024 Jun 7, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

produce-xml-converter.xsl should have unit-level XSpec tests
2 participants