[libvirt] [PATCH 2/2] news: Allow empty <section> elements

Andrea Bolognani posted 2 patches 8 years, 10 months ago
[libvirt] [PATCH 2/2] news: Allow empty <section> elements
Posted by Andrea Bolognani 8 years, 10 months ago
Creating dummy <change> elements was a workaround for the
HTML DTD not allowing empty <ul> elements, but we can do
better by tweaking the the XSLT stylesheet.
---
 docs/news-html.xsl    |  8 +++++---
 docs/news.xml         |  9 ---------
 docs/schemas/news.rng | 17 ++++++++---------
 3 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/docs/news-html.xsl b/docs/news-html.xsl
index dcbab86..dd323f9 100644
--- a/docs/news-html.xsl
+++ b/docs/news-html.xsl
@@ -57,9 +57,11 @@
       <strong>
         <xsl:value-of select="@title"/>
       </strong>
-      <ul>
-        <xsl:apply-templates select="change"/>
-      </ul>
+      <xsl:if test="*">
+        <ul>
+          <xsl:apply-templates select="change"/>
+        </ul>
+      </xsl:if>
     </li>
   </xsl:template>
 
diff --git a/docs/news.xml b/docs/news.xml
index 9eb4d21..732d359 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -23,19 +23,10 @@
 
   <release version="FIXME" date="unreleased">
     <section title="New features">
-      <change>
-        <summary/>
-      </change>
     </section>
     <section title="Improvements">
-      <change>
-        <summary/>
-      </change>
     </section>
     <section title="Bug fixes">
-      <change>
-        <summary/>
-      </change>
     </section>
   </release>
 
diff --git a/docs/schemas/news.rng b/docs/schemas/news.rng
index 94a6870..9212c3c 100644
--- a/docs/schemas/news.rng
+++ b/docs/schemas/news.rng
@@ -35,21 +35,20 @@
       <attribute name="title">
         <data type="string"/>
       </attribute>
-      <oneOrMore>
-        <ref name="change"/>
-      </oneOrMore>
+      <optional>
+        <oneOrMore>
+          <ref name="change"/>
+        </oneOrMore>
+      </optional>
     </element>
   </define>
 
   <define name="change">
     <element name="change">
       <element name="summary">
-        <choice>
-          <data type="string">
-            <param name="pattern">\n[^\n]+\n +</param>
-          </data>
-          <empty/>
-        </choice>
+        <data type="string">
+          <param name="pattern">\n[^\n]+\n +</param>
+        </data>
       </element>
       <optional>
         <element name="description">
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] news: Allow empty <section> elements
Posted by Martin Kletzander 8 years, 10 months ago
On Thu, Mar 30, 2017 at 03:45:27PM +0200, Andrea Bolognani wrote:
>Creating dummy <change> elements was a workaround for the
>HTML DTD not allowing empty <ul> elements, but we can do
>better by tweaking the the XSLT stylesheet.
>---
> docs/news-html.xsl    |  8 +++++---
> docs/news.xml         |  9 ---------
> docs/schemas/news.rng | 17 ++++++++---------
> 3 files changed, 13 insertions(+), 21 deletions(-)
>
>diff --git a/docs/news.xml b/docs/news.xml
>index 9eb4d21..732d359 100644
>--- a/docs/news.xml
>+++ b/docs/news.xml
>@@ -23,19 +23,10 @@
>
>   <release version="FIXME" date="unreleased">
>     <section title="New features">
>-      <change>
>-        <summary/>
>-      </change>
>     </section>
>     <section title="Improvements">
>-      <change>
>-        <summary/>
>-      </change>
>     </section>
>     <section title="Bug fixes">
>-      <change>
>-        <summary/>
>-      </change>
>     </section>
>   </release>
>

I think this defeats the purpose of the template.  But on the other hand
you can see how the change looks like in previous releases and git
history etc.

>diff --git a/docs/schemas/news.rng b/docs/schemas/news.rng
>index 94a6870..9212c3c 100644
>--- a/docs/schemas/news.rng
>+++ b/docs/schemas/news.rng
>@@ -35,21 +35,20 @@
>       <attribute name="title">
>         <data type="string"/>
>       </attribute>
>-      <oneOrMore>
>-        <ref name="change"/>
>-      </oneOrMore>
>+      <optional>
>+        <oneOrMore>
>+          <ref name="change"/>
>+        </oneOrMore>
>+      </optional>

Instead of this, you can use zeroOrMore.

ACK series, with that changed if you are okay with the fact that I know
XSL even less than RNG O=)
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] news: Allow empty <section> elements
Posted by Daniel P. Berrange 8 years, 10 months ago
On Thu, Mar 30, 2017 at 03:45:27PM +0200, Andrea Bolognani wrote:
> Creating dummy <change> elements was a workaround for the
> HTML DTD not allowing empty <ul> elements, but we can do
> better by tweaking the the XSLT stylesheet.
> ---
>  docs/news-html.xsl    |  8 +++++---
>  docs/news.xml         |  9 ---------
>  docs/schemas/news.rng | 17 ++++++++---------
>  3 files changed, 13 insertions(+), 21 deletions(-)
> 
> diff --git a/docs/news-html.xsl b/docs/news-html.xsl
> index dcbab86..dd323f9 100644
> --- a/docs/news-html.xsl
> +++ b/docs/news-html.xsl
> @@ -57,9 +57,11 @@
>        <strong>
>          <xsl:value-of select="@title"/>
>        </strong>
> -      <ul>
> -        <xsl:apply-templates select="change"/>
> -      </ul>
> +      <xsl:if test="*">
> +        <ul>
> +          <xsl:apply-templates select="change"/>
> +        </ul>
> +      </xsl:if>
>      </li>
>    </xsl:template>
>  
> diff --git a/docs/news.xml b/docs/news.xml
> index 9eb4d21..732d359 100644
> --- a/docs/news.xml
> +++ b/docs/news.xml
> @@ -23,19 +23,10 @@
>  
>    <release version="FIXME" date="unreleased">
>      <section title="New features">
> -      <change>
> -        <summary/>
> -      </change>
>      </section>
>      <section title="Improvements">
> -      <change>
> -        <summary/>
> -      </change>
>      </section>
>      <section title="Bug fixes">
> -      <change>
> -        <summary/>
> -      </change>
>      </section>
>    </release>
>  
> diff --git a/docs/schemas/news.rng b/docs/schemas/news.rng
> index 94a6870..9212c3c 100644
> --- a/docs/schemas/news.rng
> +++ b/docs/schemas/news.rng
> @@ -35,21 +35,20 @@
>        <attribute name="title">
>          <data type="string"/>
>        </attribute>
> -      <oneOrMore>
> -        <ref name="change"/>
> -      </oneOrMore>
> +      <optional>
> +        <oneOrMore>
> +          <ref name="change"/>
> +        </oneOrMore>
> +      </optional>
>      </element>
>    </define>
>  
>    <define name="change">
>      <element name="change">
>        <element name="summary">
> -        <choice>
> -          <data type="string">
> -            <param name="pattern">\n[^\n]+\n +</param>
> -          </data>
> -          <empty/>
> -        </choice>
> +        <data type="string">
> +          <param name="pattern">\n[^\n]+\n +</param>
> +        </data>
>        </element>
>        <optional>
>          <element name="description">

FYI, it looks like something in this change has broken schema validation
on RHEL-6 vintage libxml

https://ci.centos.org/view/libvirt/job/libvirt-master-check/systems=libvirt-centos-6/298/console

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] news: Allow empty <section> elements
Posted by Andrea Bolognani 8 years, 10 months ago
On Mon, 2017-04-03 at 17:54 +0100, Daniel P. Berrange wrote:
> >    <define name="change">
> >      <element name="change">
> >        <element name="summary">
> > -        <choice>
> > -          <data type="string">
> > -            <param name="pattern">\n[^\n]+\n +</param>
> > -          </data>
> > -          <empty/>
> > -        </choice>
> > +        <data type="string">
> > +          <param name="pattern">\n[^\n]+\n +</param>
> > +        </data>
> >        </element>
> >        <optional>
> >          <element name="description">
> 
> FYI, it looks like something in this change has broken schema validation
> on RHEL-6 vintage libxml
> 
> https://ci.centos.org/view/libvirt/job/libvirt-master-check/systems=libvirt-centos-6/298/console

It was broken by introducing validation of release notes in the
first place, not by tweaking the schema. I believe someone is
already looking into it.

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list