xml - Testing for matching file names in Schematron -



xml - Testing for matching file names in Schematron -

i have xml document list of xml, pdf, , tif files. need test via schematron each xml has matching pdf file, , vice versa.

my xml:

<folder> <files> <file>foo.xml</file> <file>foo.pdf</file> <file>bar.xml</file> <!-- missing file <file>bar.pdf</file> --> <file>foo.tif</file> </files> </folder>

my schematron:

<schema xmlns="http://purl.oclc.org/dsdl/schematron" querybinding="xslt2"> <!-- xml/pdf matches --> <pattern abstract="false" id="xmlpdfpair"> <rule context="folder/files//file"> <assert test="substring-before(.,'.xml') eq substring-before(.,'.pdf')">the xml or pdf (<value-of select="."/>) not have matching pdf or xml file.</assert> </rule> </pattern>

i want rule fire on missing bar.pdf should nowadays in file. schematron not doing trick. sense need for-each build here. utilize of keys create simpler?

change mentioned desired validation:

<pattern abstract="false" id="xmlpdfpair"> <rule context="//file[contains(text(),'.xml')]"> <let name="filename" value="substring-before(.,'.xml')"/> <assert test="(following-sibling::file)[1][text()=concat($filename,'.pdf')]">the xml or pdf (<value-of select="."/>) not have matching pdf or xml file.</assert> </rule> </pattern>

xml xpath-2.0 schematron

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -