Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF swallows closing tag after SVG

I'm using two <svg> elements inside a <ul>.

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"      
    xmlns:h="http://java.sun.com/jsf/html">

...
<ul>
    <li>
        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" >...</svg>
    </li>
    <li>
        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" >...</svg>
    </li>
</ul>
...
</html>

JSF is swallowing the first closing </li> when it's rendering the HTML.

Is this a bug or is my xhtml invalid?

I'm using Mojarra 2.1.7.

Update: As @BalusC suggested I reported this to the Mojarra Guys.

Update 2: Fixed with Mojarra 2.1.26 and 2.2.3

like image 842
lefloh Avatar asked Jul 26 '13 07:07

lefloh


1 Answers

I can reproduce it in 2.1.24. I'm not sure if this is a bug in Facelets' SAX parser but it indeed look much like that it got confused in nested namespaces. You're with <svg xmlns> declaring a new default XML namespace which has seemingly overriden the <html xmlns> one for HTML tags. I recommend to report this issue to Mojarra guys.

In any case, the right way of using SVG in Facelets is to split off the whole <svg> content into its own .svg file and include it via <ui:include>.

<ul>
    <li>
        <ui:include src="/resources/svg/one.svg" />
    </li>
    <li>
        <ui:include src="/resources/svg/two.svg" />
    </li>
</ul>

This way the namespacing works fine. Additional benefit is, your SVGs are this way instantly reusable.

like image 102
BalusC Avatar answered Nov 28 '22 09:11

BalusC