2

I have an file which will either be empty, or will contain a single line with a single string value.

I can consume the file contents in either an XPath expression evaluator or in an XSL transform, version 1.

I simply need to know if there is a value in the file or not.

As far as I know, both tools require correctly formed XML.

Do I have any options?

(It's a boring story about why I only have XPath or XSLT 1.0 available to me)

1 Answer 1

1

You're right that XPath and XSLT generally operate on well-formed XML, and an empty file is not well formed XML because it lacks a single root element.

XSLT 2.0, however, can read non-XML via unparsed-text(). That's your ticket for exploring empty or any other text that's not well-formed XML using XSLT.

If you only have XSLT 1.0, then you're out of luck if you can't operate outside of XSLT 1.0 via preprocessing or using non-standard extensions.

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

2 Comments

Thanks for your answer. Sadly, I am working within an existing framework and XSLT 1 is my only option :(
Then as you anticipated, you're out of luck. Sorry. Answer updated to make that more clear.

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.