Search code examples
xmlxsdxsd-validation

Validate XML filename


Is it possible to also validate an XML's filename? I want to fail validation if the file is not named <componentType>-<name>.xml, where componentType and name are elements in the XML.

Of course I could run some bash script using xpath, but here I don't have that option.


Solution

  • Not using XSD directly (and I'm not sure why you would want to).

    You could possibly use an XSD 1.1 assertion to test the value of base-uri(), but it's not going to be 100% reliable - whoever requests the validation has plenty of ways of failing to inform the validator of the document's location, or of misinforming it.