Author: crossley Date: Sun Jun 7 08:18:04 2009 New Revision: 782343 URL: http://svn.apache.org/viewvc?rev=782343&view=rev Log: Enable validation of intermediate xml of all documents. Issue: FOR-1172
Added: forrest/trunk/main/webapp/resources/stylesheets/linkmap-to-validation.xsl (with props) forrest/trunk/main/webapp/resources/stylesheets/validation-insert-filename.xsl (with props) forrest/trunk/main/webapp/resources/stylesheets/validation-reports.xsl (with props) forrest/trunk/site-author/conf/uris.txt (with props) Modified: forrest/trunk/main/targets/site.xml forrest/trunk/main/webapp/linkmap.xmap forrest/trunk/site-author/content/xdocs/howto-dev.xml forrest/trunk/site-author/content/xdocs/site.xml forrest/trunk/site-author/forrest.properties forrest/trunk/site-author/status.xml Modified: forrest/trunk/main/targets/site.xml URL: http://svn.apache.org/viewvc/forrest/trunk/main/targets/site.xml?rev=782343&r1=782342&r2=782343&view=diff ============================================================================== --- forrest/trunk/main/targets/site.xml (original) +++ forrest/trunk/main/targets/site.xml Sun Jun 7 08:18:04 2009 @@ -176,6 +176,44 @@ Copying broken links file to site root. </echo> <copy toFile="${project.site-dir}/broken-links.xml" file="${project.brokenlinkfile}"/> +<!-- FIXME: need better way to determine *.validation.xml are present --> + <available property="project.validation.content.present" + file="${project.site-dir}/index.validation.xml"/> + <if> + <equals arg1="${project.validation.content.present}" arg2="true"/> + <then> + <echo message="Assembling validation report ..."/> +<!-- FIXME: See Ant - Bug 18897 Add option to suppress xslt warning messages + Available in upcoming Ant-1.8.0 +--> + <xslt basedir="${project.site-dir}" destdir="${project.temp-dir}/validation" + extension=".xml" + includes="**/*.validation.xml" + style="${forrest.core.webapp}/resources/stylesheets/validation-insert-filename.xsl" + filenameparameter="filename" + filedirparameter="filedir" + /> + <replaceregexp byline="true"> + <regexp pattern="^<\?[^?>]+\?>"/> + <substitution expression=""/> + <fileset dir="${project.temp-dir}/validation" includes="**/*.validation.xml"/> + </replaceregexp> + <concat destfile="${project.temp-dir}/validation/reports.xml" fixlastline="yes"> + <header><?xml version="1.0" encoding="UTF-8"?> + <reports></header> + <fileset dir="${project.temp-dir}/validation" includes="**/*.validation.xml"/> + <footer></reports></footer> + </concat> + <xslt in="${project.temp-dir}/validation/reports.xml" + out="${project.temp-dir}/validation-reports.html" + style="${forrest.core.webapp}/resources/stylesheets/validation-reports.xsl"/> + <delete> + <fileset dir="${project.site-dir}" includes="**/*.validation.xml"/> + </delete> + <delete file="${project.site-dir}/linkmap.validation-start.xml"/> + <delete dir="${project.temp-dir}/validation"/> + </then> + </if> </sequential> <if> <equals arg1="${buildResult}" arg2="1"/> Modified: forrest/trunk/main/webapp/linkmap.xmap URL: http://svn.apache.org/viewvc/forrest/trunk/main/webapp/linkmap.xmap?rev=782343&r1=782342&r2=782343&view=diff ============================================================================== --- forrest/trunk/main/webapp/linkmap.xmap (original) +++ forrest/trunk/main/webapp/linkmap.xmap Sun Jun 7 08:18:04 2009 @@ -46,6 +46,17 @@ <map:transform src="{lm:transform.linkmap.document}"/> <map:serialize type="xml" /> </map:match> + <map:match pattern="linkmap.validation-start.xml"> + <map:generate src="cocoon://linkmap.html"/> + <map:transform src="{lm:transform.linkmap.validation}"/> + <map:serialize type="xml" /> + </map:match> + <map:match pattern="linkmap.validation.xml"> + <map:generate src="cocoon://linkmap.xml"/> + <map:transform type="validation-report" + src="{forrest:forrest.context}/resources/schema/relaxng/unstable/document-v13.rng"/> + <map:serialize type="xml"/> + </map:match> <!-- site.xml with @href's appended to be context-relative. --> <map:match pattern="abs-linkmap"> <map:generate src="cocoon://site.navigation.links.xml"/> Added: forrest/trunk/main/webapp/resources/stylesheets/linkmap-to-validation.xsl URL: http://svn.apache.org/viewvc/forrest/trunk/main/webapp/resources/stylesheets/linkmap-to-validation.xsl?rev=782343&view=auto ============================================================================== --- forrest/trunk/main/webapp/resources/stylesheets/linkmap-to-validation.xsl (added) +++ forrest/trunk/main/webapp/resources/stylesheets/linkmap-to-validation.xsl Sun Jun 7 08:18:04 2009 @@ -0,0 +1,38 @@ +<?xml version='1.0'?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:template match="body"> + <ul> + <xsl:apply-templates select="//li"/> + </ul> + </xsl:template> + <xsl:template match="li"> + <xsl:apply-templates select="a|link"/> + </xsl:template> + <xsl:template match="a|link"> + <xsl:if test="@href!='' and not(contains(@href, ':')) and contains(@href, '.html')"> + <link> + <xsl:attribute name="href"> + <xsl:value-of select="concat(substring-before(@href,'.html'),'.validation.xml')" /> + </xsl:attribute> + <xsl:value-of select="."/> + </link> + </xsl:if> + </xsl:template> + <xsl:template match="head"/> +</xsl:stylesheet> Propchange: forrest/trunk/main/webapp/resources/stylesheets/linkmap-to-validation.xsl ------------------------------------------------------------------------------ svn:eol-style = native Added: forrest/trunk/main/webapp/resources/stylesheets/validation-insert-filename.xsl URL: http://svn.apache.org/viewvc/forrest/trunk/main/webapp/resources/stylesheets/validation-insert-filename.xsl?rev=782343&view=auto ============================================================================== --- forrest/trunk/main/webapp/resources/stylesheets/validation-insert-filename.xsl (added) +++ forrest/trunk/main/webapp/resources/stylesheets/validation-insert-filename.xsl Sun Jun 7 08:18:04 2009 @@ -0,0 +1,41 @@ +<?xml version='1.0'?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<xsl:stylesheet version="1.0" exclude-result-prefixes="v" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:v="http://apache.org/cocoon/validation/1.0"> + <xsl:param name="filename"></xsl:param> + <xsl:param name="filedir"></xsl:param> + <xsl:template match="/"> + <xsl:apply-templates/> + </xsl:template> + <xsl:template match="v:report"> + <report> + <xsl:attribute name="filename"> + <xsl:value-of select="$filedir"/> + <xsl:text>/</xsl:text> + <xsl:value-of select="$filename"/> + </xsl:attribute> + <xsl:apply-templates/> + </report> + </xsl:template> + <xsl:template match="v:error"> + <error> + <xsl:apply-templates/> + </error> + </xsl:template> +</xsl:stylesheet> Propchange: forrest/trunk/main/webapp/resources/stylesheets/validation-insert-filename.xsl ------------------------------------------------------------------------------ svn:eol-style = native Added: forrest/trunk/main/webapp/resources/stylesheets/validation-reports.xsl URL: http://svn.apache.org/viewvc/forrest/trunk/main/webapp/resources/stylesheets/validation-reports.xsl?rev=782343&view=auto ============================================================================== --- forrest/trunk/main/webapp/resources/stylesheets/validation-reports.xsl (added) +++ forrest/trunk/main/webapp/resources/stylesheets/validation-reports.xsl Sun Jun 7 08:18:04 2009 @@ -0,0 +1,54 @@ +<?xml version='1.0'?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:template match="/"> + <html> + <head> + <title>Validation reports</title> + </head> + <body> + <h1>Validation reports</h1> + <xsl:apply-templates/> + </body> + </html> + </xsl:template> + <xsl:template match="reports"> + <xsl:apply-templates/> + </xsl:template> + <xsl:template match="report"> + <xsl:variable name="fn"> + <xsl:value-of select="substring-before(@filename, '.validation.xml')"/> + </xsl:variable> + <p><strong><xsl:value-of select="$fn"/></strong>.validation.xml</p> + <ul> + <xsl:choose> + <xsl:when test="count(error)=0"> + <li>No errors</li> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates/> + </xsl:otherwise> + </xsl:choose> + </ul> + </xsl:template> + <xsl:template match="error"> + <li> + <xsl:apply-templates/> + </li> + </xsl:template> +</xsl:stylesheet> Propchange: forrest/trunk/main/webapp/resources/stylesheets/validation-reports.xsl ------------------------------------------------------------------------------ svn:eol-style = native Added: forrest/trunk/site-author/conf/uris.txt URL: http://svn.apache.org/viewvc/forrest/trunk/site-author/conf/uris.txt?rev=782343&view=auto ============================================================================== --- forrest/trunk/site-author/conf/uris.txt (added) +++ forrest/trunk/site-author/conf/uris.txt Sun Jun 7 08:18:04 2009 @@ -0,0 +1 @@ +linkmap.validation-start.xml Propchange: forrest/trunk/site-author/conf/uris.txt ------------------------------------------------------------------------------ svn:eol-style = native Modified: forrest/trunk/site-author/content/xdocs/howto-dev.xml URL: http://svn.apache.org/viewvc/forrest/trunk/site-author/content/xdocs/howto-dev.xml?rev=782343&r1=782342&r2=782343&view=diff ============================================================================== --- forrest/trunk/site-author/content/xdocs/howto-dev.xml (original) +++ forrest/trunk/site-author/content/xdocs/howto-dev.xml Sun Jun 7 08:18:04 2009 @@ -489,14 +489,12 @@ The Validation Block is already added to Forrest and configured. To use it simply add entries to your sitemap like this and followed by a serializer: </p> - <source> -<![CDATA[ + <source><![CDATA[ ... <map:transform type="validation-report" src="{forrest:forrest.context}/resources/schema/relaxng/unstable/any.rng"/> ... -]]> - </source> +]]></source> <p> That can be added at any point where you want to validate the xml. There is a default validation by reqesting the URI @@ -513,6 +511,23 @@ See <a href="http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/components/validation/Validator.html">API</a> docs. </p> </section> + <section id="validate-intermediate"> + <title>Validate all intermediate xml content</title> + <p> + Add a text file at <code>src/documentation/conf/uris.txt</code> + which contains the line <code>linkmap.validation-start.xml</code> + (and any other extra URIs that you want Cocoon to process). + </p> + <p> + Add the line + <code>project.urifile=${project.home}/src/documentation/conf/uris.txt</code> + to your project's <code>forrest.properties</code> file. + </p> + <p> + After generating the complete site with '<code>forrest site</code>' + see the document <code>build/tmp/validation-reports.html</code> + </p> + </section> <section id="debug-java"> <title>Java code</title> <p> Modified: forrest/trunk/site-author/content/xdocs/site.xml URL: http://svn.apache.org/viewvc/forrest/trunk/site-author/content/xdocs/site.xml?rev=782343&r1=782342&r2=782343&view=diff ============================================================================== --- forrest/trunk/site-author/content/xdocs/site.xml (original) +++ forrest/trunk/site-author/content/xdocs/site.xml Sun Jun 7 08:18:04 2009 @@ -101,6 +101,7 @@ <debug-cocoon-profiler href="#debug-cocoon-profiler"/> <debug-sitemap-exec href="#debug-sitemap-exec"/> <debug-validation href="#debug-validation"/> + <validate-intermediate href="#validate-intermediate"/> </forrest-dev> <forrestbot-svn label="Forrestbot svn" href="howto-forrestbot-svn.html" description="Publish documentation with Forrestbot svn workstage"/> Modified: forrest/trunk/site-author/forrest.properties URL: http://svn.apache.org/viewvc/forrest/trunk/site-author/forrest.properties?rev=782343&r1=782342&r2=782343&view=diff ============================================================================== --- forrest/trunk/site-author/forrest.properties (original) +++ forrest/trunk/site-author/forrest.properties Sun Jun 7 08:18:04 2009 @@ -25,6 +25,7 @@ project.xdocs-dir=${project.content-dir}/content/xdocs project.raw-content-dir=${project.content-dir}/content project.configfile=${project.home}/conf/cli.xconf +project.urifile=${project.home}/conf/uris.txt project.skinconf=${project.content-dir}/skinconf.xml project.bugtracking-url=http://issues.apache.org/jira/browse/ Modified: forrest/trunk/site-author/status.xml URL: http://svn.apache.org/viewvc/forrest/trunk/site-author/status.xml?rev=782343&r1=782342&r2=782343&view=diff ============================================================================== --- forrest/trunk/site-author/status.xml (original) +++ forrest/trunk/site-author/status.xml Sun Jun 7 08:18:04 2009 @@ -162,6 +162,9 @@ <action context="code" type="add" dev="DC" fixes-bug="FOR-1172" importance="high"> Added the ability to use RELAXNG to validate intermediate xml. Do 'localhost:8888/index.validation.xml' for example. + Also see how to + <link href="site:procedures/forrest-dev/validate-intermediate">validate intermediate</link> + content for the whole site. </action> <!-- 2009-05 --> <action context="code" type="add" dev="DC" fixes-bug="FOR-1170" importance="high">