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?
1 Answer
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.
1 Comment
Willfergy
Thanks everyone, this is what I feared but I couldn't find a solid answer anywhere.
Premature end of fileerror 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?