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

You can't serialize a free-floating attribute node #1131

Closed
ndw opened this issue Jan 12, 2025 · 6 comments · Fixed by #1138
Closed

You can't serialize a free-floating attribute node #1131

ndw opened this issue Jan 12, 2025 · 6 comments · Fixed by #1138

Comments

@ndw
Copy link
Contributor

ndw commented Jan 12, 2025

In the section on text value templates, we say that inserting XML into a non-XML document via a TVT inserts the serialization. But there's evidence in the wild of this usage:

<p:inline content-type="text/plain">{/*/@name}</p:inline>

with the expectation that the value of the name attribute is inserted. Either we need to special case inserting free-floating attributes or that's an error.

@ndw
Copy link
Contributor Author

ndw commented Jan 12, 2025

Having fixed a bug where I was doing TVTs in text/plain incorrectly, I have to say I'm unhappy with the results. Consider:

<p:with-input>
  <p:inline content-type="text/plain" expand-text="false"><![CDATA[
print("<?xml version='1.0'?>")
print(f"<doc>Testing {x*y}</doc>")
  ]]></p:inline>
</p:with-input>

Unless I've done something else wrong, absolutely a possibility, that produces:

print("&amp;amp;lt;?xml version='1.0'?&amp;amp;gt;")
print(f"&amp;amp;lt;doc&amp;amp;gt;Testing {x*y}&amp;amp;lt;/doc&amp;amp;gt;")

Which is ... utterly useless.

@ndw
Copy link
Contributor Author

ndw commented Jan 12, 2025

Setting aside, for a moment, the annoying problem of backwards incompatibility, having the TVT output be special variation on cast-content-type seems wrong. Maybe serializing with the text method makes more sense.

@xml-project
Copy link
Member

Maybe serializing with the text method makes more sense.

Yes, I think that makes much more sense. Seriously I can't hardly think about a use case for adding nodes with method "xml" here.
For the "free-floating attribute node" we could either say it's an error or invent a special case using their string values.

@gimsieke
Copy link
Contributor

Can’t we tell people to write <p:inline content-type="text/plain">{string(/*/@name)}</p:inline>?

@ndw
Copy link
Contributor Author

ndw commented Jan 31, 2025

Document that it's technically incompatible, but can't possibly be useful. Editor to figure out what to do with the error code. Agree with Gerrit, use string().

@ndw
Copy link
Contributor Author

ndw commented Feb 2, 2025

I couldn't find a suitable error so I added err:XD0084.

ndw added a commit to ndw/3.0-specification that referenced this issue Feb 4, 2025
Fix xproc#1131

1. Make the backwards-incompatible change that TVTs are serialized as text, not
XML, when they occur in content types that are not XML or HTML content types.
2. Correct the examples, observing that special case has to be taken with quotes
in JSON.
3. Add explicit error (err:XD0052) for attempting to output a
free-floating attribute node if the content type is not XML or HTML.
@ndw ndw closed this as completed in #1138 Feb 4, 2025
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 a pull request may close this issue.

3 participants