Skip to content

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Jan 19, 2025

RFC text to be written, WIP
Adds functionality to load XML/HTML from an already opened stream.

@nielsdos
Copy link
Member Author

cc @veewee @theseer maybe this is of interest for you

@frederikbosch
Copy link
Contributor

This an interesting feature (again). Another method I would love to see - which is very close to this PR - is XSLTProcessor::transformToStream. In that case XSLTProcessor::transformToUri would become a simplified version of the new transformToStream method.

@veewee veewee mentioned this pull request Jan 29, 2025
1 task
@nielsdos
Copy link
Member Author

Hi Frederik

That makes sense, and shouldn't be hard at all to add.
Something like public XSLTProcessor::transformToStream(object $document, /*resource*/ $stream): int should do.
The return value is up to debate I suppose. transformToUri returns an int that gives the number of written bytes on success, and -1 on failure. While transformToXml returns false or null on error, confusingly. We aren't really a fan of int|false returns any more because of the coercion between 0 and false when doing a == comparison. So I suppose in the exceptional case where no output could be generated an exception should be thrown. Feel free to give your opinion.

@frederikbosch
Copy link
Contributor

Not a fan of int|falseeither. I'd prefer an exception when the method fails. So void would be sufficient. When one needs to know the number of bytes written, one could check the size of the stream before and after the operation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants