TEIC / Stylesheets

TEI XSL Stylesheets
234 stars 125 forks source link

ANT transformations don't work in Oxygen XML Editor with certain document #476

Closed sorincarbunaru closed 2 years ago

sorincarbunaru commented 4 years ago

If I try to publish the XML document from inside facsimile.zip to EPUB, DOCX or ODT, I get the following error:

Transformation failed. C:\Users\SORIN_~1\AppData\Local\Temp\build1731161873\copy.xml:1: Use a resource collection to copy directories.

The problem seems to be related to <pb facs="#B49r"/> from inside the document.

Note that the XHTML and PDF transformations run fine.

dmj commented 4 years ago

I can confirm this error. The <pb facs="#B49r"/> refers to a non-existent element with an xml:id of B49r. https://github.com/TEIC/Stylesheets/blob/f410b156d26dc3b6e845f14faf1681e176e7a6b1/tools/makegraphicsanttask.xsl#L117 fails to realize this and creates an ANT copy task with an invalid source.

martindholmes commented 4 years ago

I think the Stylesheets should fail gracefully on this, but surely it's an error in the encoding if you have a link to a non-existent id?

dmj commented 4 years ago

I think we could use the following rule of thumb: We don't create the Ant task If we can figure out that it will fail. This is the case when the target of @facs is missing but also e.g. when @url of a graphic is empty.

In a "Stylesheets NG" I would consider always validating a document before transforming.

martindholmes commented 4 years ago

@dmj You can only validate a document if you know where the schema is, but for many large projects, schemas are not directly linked from the document; Oxygen project settings, validation scenarios, or custom build processes take care of validation.

It's arguable that a local pointer to a missing id is not a validation issue, it's more of a well-formedness thing, and should be checked even in the absence of a schema (although I'm sure @sydb would disagree). But in this particular case, I think a graceful failure with a warning message from the XSLT would be a better option. Would you consider adding a warning message to your pull request?

dmj commented 4 years ago

@martindholmes True enough. I have this vague idea about about somehow validating a document against the preconditions for a transformation. Not sure if this is feasable tough.

dmj commented 4 years ago

It's arguable that a local pointer to a missing id is not a validation issue, it's more of a well-formedness thing, and should be checked even in the absence of a schema (although I'm sure @sydb would disagree).

I disagree, too :)

But in this particular case, I think a graceful failure with a warning message from the XSLT would be a better option. Would you consider adding a warning message to your pull request?

Sure, will do.

dmj commented 4 years ago

Created pull request https://github.com/TEIC/Stylesheets/pull/477