1

In my situation I have a automated XSLT (1.0) running, transforming files to a SOAP format and pushing them over a WSDL. However, because the source is unreliable for good input data sometimes the XML files I have to pick up and process are blank. Is there a way to inject these files a value during transformation and output or ignore these blank files?

2
  • What exactly do you mean by "blank"? Do you mean a file with literally zero content (zero bytes), or do you mean a file that has XML elements, but none of them are populated? If the former, I don't think any pure XSL engine will accept empty files -- Saxon, for instance, spits out a Premature end of file error if the input file is completely empty. If the input file has content that isn't valid, well-formed XML, Saxon spits out different errors. How are you processing the files? Commented May 2, 2017 at 23:44
  • If a file is "blank" then it isn't an XML file. Commented May 3, 2017 at 7:51

1 Answer 1

1

No, the input to an XSLT 1.0 transformation must be a well-formed XML document, and to be well-formed, an XML document must be have single root element. Therefore, your transformation cannot take a blank (empty) document as input.

Fix the broken source of the empty "XML" documents, or pre-process the file before it hits the XSLT transformation.

See also How to read plain text content with XSLT 1.0 for some additional alternatives.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks everyone, this is what I feared but I couldn't find a solid answer anywhere.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.