XML test scripts / runners

Is there any xml testing frameworks out there that would allow me to write scripts for testing/asserting contents of an xml file??

Note: I know that such frameworks exist as extensions for programming language testing frameworks such as Java and .NET.

What I am looking is having something independent of any programming language. I would like to write xml testing scripts in notepad and not have to compile them. (Something like DBFit but for XML). See below for an example of what I am looking for.

Sample XML

  <parent>
          <value name ="bob"/>
  </parent>

-->

Sample XML Test Script

assert(xpath("/parent/value/@name") == 'bob');

Answers


You could roll your own solution fairly easily using XSLT.

Here is an example of an XSLT that evaluates your assertion criteria and if it does not pass, uses xsl:message with @terminate='yes' to halt the process and echo the error message to std out:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" exclude-result-prefixes="xd" version="1.0">
    <xsl:template match="/">
        <!--Assert that /parent/value/@name == 'bob'-->
        <xsl:if test="not(/parent/value/@name='bob')">
            <!-- if it does not, then terminate the transform and fail -->
            <xsl:message terminate="yes">name must be bob</xsl:message>
        </xsl:if>
    </xsl:template>
</xsl:stylesheet>

Simply execute the XSLT against the file(s) that you want to validate.


Need Your Help

How can I submit this form using json to another page and parse json in PHP or jQuery?

php json

I know this seems like I should have immediately found the one example out there that simply explained this concept, and I can't find the right one. The examples in tutorials out there use flickr ...

Could not find any resources appropriate for the specified culture. baseName: EkResource.en-US

c# asp.net ektron

I have a Website project in Asp.Net 3.5 and Ektron. The website is running fine in my local machine. But when I am trying to set up the code in a new machine it is giving me the below error.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.