I’m trying a little to use XSLT for purposes other than its intended purpose, namely, to output a report on incorrect XML writing (after checking XSD with a scheme, there are some subtleties that the scheme cannot take into account).
In particular, I encountered a verification problem: If the @A attribute is false, then the @B attribute must be present and has any value (the value itself is checked by the schema).
Made an XSLT template that gets to the desired tag and finds the @A attribute with a value of 'false'. How to check that the @B attribute is missing in this element?
The result of such checks forms an HTML document with a list of errors found.
XSLT looks something like this:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:vw="tableview.xsd"> <xsl:output method="html"/> <xsl:template match="/"> <html> <body> <table> <xsl:apply-templates select="vw:template/vw:cells/vw:block"></xsl:apply-templates> </table> </body> </html> </xsl:template> <xsl:template match="text() | @*"> <xsl:apply-templates></xsl:apply-templates> </xsl:template> <xsl:template match="vw:block"> <xsl:for-each select="vw:cell"> <xsl:if test="@readonly='false' and @type = null"> ///Здесь @type = null сам придумал. Не знаю как понять отсутствие атрибута <tr> <td> Атрибут readonly имеет значение <xsl:value-of select="@readonly"/> и атрибут type имеет значение <xsl:value-of select="@type"/> </td> </tr> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet> If you have any comments on the code, I will also listen with pleasure. I get acquainted with XSLT the first day. A part of the "quick start" documentation from msdn.microsoft read, but this is clearly not enough.