Lists Home |
Date Index |
XSLT works for this kind of thing and its pretty easy, too. Say the file
data.xml is expected to contain the elements cow and chicken but
Here's an XSLT stylesheet that checks for the the cow and chicken elements
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:message>chicken element not found</xsl:message>
<xsl:message>cow element not found</xsl:message>
<xsl:message>All needed elements found</xsl:message>
If data.xml contains both cow and chicken, you'll get a report saying that
all the needed elements are found. If not, you get a complaint:
C:\XML\Examples>saxon data.xml check.xsl
cow element not found
Hope this works for you.
Noah Genner wrote:
> Hello All,
> I'm new to all this and I'm looking for some direction.
> I need to be able to check an XML document for some specific elements, and if
> possible produce a little report on which ones are missing. The document has
> already been validated against a dtd/schema that contains approximately 270
> elements, but I need to check that the ~40 I need are present. If they aren't
> present I want to produce a little report that says which elements are not present.
> Can I do this with XSLT, or is there an easier way to do this?