Thread: [Xsltforms-support] XSLTForms and SVG
Brought to you by:
alain-couthures
|
From: Tim T. <tim...@gm...> - 2016-01-19 13:11:57
|
Alain, I am hoping to do some work with XForms and SVG and have been looking at the current XSLTForms SVG examples. I noticed that, since rev. 595 of XSLTForms, none of the SVG examples work in Firefox. The reason seems to be the changes made to the fallback identity template in xsltforms.xsl. In the latest revision, if lines 1203-1228[1] are reverted back to the template used prior to rev. 595, then the SVG examples will work in Firefox: <xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform" match="node()|@*" priority="-2"> <xsl:param name="appearance" select="@appearance"/> <xsl:param name="parentworkid"/> <xsl:param name="workid" select="concat(position(),'_',$parentworkid)"/> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates select="node()"> <xsl:with-param name="parentworkid" select="$workid"/> <xsl:with-param name="appearance" select="$appearance"/> </xsl:apply-templates> </xsl:copy> </xsl:template> Is there a reason not to use this more generic template? I tested on a range of browsers and did not notice any immediate issues. Thanks again! Tim [1] https://github.com/AlainCouthures/xsltforms/blob/master/build/xsltforms.xsl#L1203 -- Tim A. Thompson Metadata Librarian (Spanish/Portuguese Specialty) Princeton University Library |
|
From: Alain C. <ala...@ag...> - 2016-01-19 18:21:18
|
Tim, Thank you for pointing at this issue! XSLTForms stylesheet has to deal with namespaces: the best approach for browsers appears to deliver no namespace for HTML. Using <xsl:copy> is not a good solution and using <xsl:element> and <xsl:attribute> allows to remove the XHTML namespace. BTW, with the previous template, Saxon was complaining that attributes cannot have attributes... So, I prefer improve the current templates with non-HTML namespaces support, such as SVG, at least for elements: <xsl:template match="*" priority="-2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="appearance" select="@appearance"/> <xsl:param name="parentworkid"/> <xsl:param name="workid" select="concat(position(),'_',$parentworkid)"/> <xsl:choose> <xsl:when test="namespace-uri() != '' and namespace-uri() != 'http://www.w3.org/1999/xhtml'"> <xsl:element name="{local-name()}" namespace="{namespace-uri()}"> <xsl:apply-templates select="@*"/> <xsl:apply-templates select="node()"> <xsl:with-param name="parentworkid" select="$workid"/> <xsl:with-param name="appearance" select="$appearance"/> </xsl:apply-templates> </xsl:element> </xsl:when> <xsl:otherwise> <xsl:element name="{local-name()}"> <xsl:apply-templates select="@*"/> <xsl:apply-templates select="node()"> <xsl:with-param name="parentworkid" select="$workid"/> <xsl:with-param name="appearance" select="$appearance"/> </xsl:apply-templates> </xsl:element> </xsl:otherwise> </xsl:choose> </xsl:template> I have successfully tested this with Firefox (Firefox is not anymore my default browser because of too many conformance, performance and freeze issues...). Thank you for your feedback! --Alain Le 19/01/2016 14:11, Tim Thompson a écrit : > Alain, > > I am hoping to do some work with XForms and SVG and have been looking > at the current XSLTForms SVG examples. I noticed that, since rev. 595 > of XSLTForms, none of the SVG examples work in Firefox. The reason > seems to be the changes made to the fallback identity template in > xsltforms.xsl. > > In the latest revision, if lines 1203-1228[1] are reverted back to the > template used prior to rev. 595, then the SVG examples will work in > Firefox: > > <xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > match="node()|@*" priority="-2"> > <xsl:param name="appearance" select="@appearance"/> > <xsl:param name="parentworkid"/> > <xsl:param name="workid" > select="concat(position(),'_',$parentworkid)"/> > <xsl:copy> > <xsl:apply-templates select="@*"/> > <xsl:apply-templates select="node()"> > <xsl:with-param name="parentworkid" select="$workid"/> > <xsl:with-param name="appearance" select="$appearance"/> > </xsl:apply-templates> > </xsl:copy> > </xsl:template> > > Is there a reason not to use this more generic template? I tested on a > range of browsers and did not notice any immediate issues. > > Thanks again! > Tim > > [1] > https://github.com/AlainCouthures/xsltforms/blob/master/build/xsltforms.xsl#L1203 > > > -- > Tim A. Thompson > Metadata Librarian (Spanish/Portuguese Specialty) > Princeton University Library > |
|
From: Tim T. <tim...@gm...> - 2016-01-19 21:58:33
|
Alain, Excellent--thank you for the explanation and solution! What is it with Firefox and namespaces? :-) Best regards, Tim -- Tim A. Thompson Metadata Librarian (Spanish/Portuguese Specialty) Princeton University Library On Tue, Jan 19, 2016 at 1:08 PM, Alain Couthures < ala...@ag...> wrote: > Tim, > > Thank you for pointing at this issue! > > XSLTForms stylesheet has to deal with namespaces: the best approach for > browsers appears to deliver no namespace for HTML. Using <xsl:copy> is not > a good solution and using <xsl:element> and <xsl:attribute> allows to > remove the XHTML namespace. > > BTW, with the previous template, Saxon was complaining that attributes > cannot have attributes... > > So, I prefer improve the current templates with non-HTML namespaces > support, such as SVG, at least for elements: > > <xsl:template match="*" priority="-2" xmlns:xhtml= > "http://www.w3.org/1999/xhtml" <http://www.w3.org/1999/xhtml> xmlns:xsl= > "http://www.w3.org/1999/XSL/Transform" > <http://www.w3.org/1999/XSL/Transform>> > <xsl:param name="appearance" select="@appearance"/> > <xsl:param name="parentworkid"/> > <xsl:param name="workid" > select="concat(position(),'_',$parentworkid)"/> > <xsl:choose> > <xsl:when test="namespace-uri() != '' and namespace-uri() != ' > http://www.w3.org/1999/xhtml'"> > <xsl:element name="{local-name()}" > namespace="{namespace-uri()}"> > <xsl:apply-templates select="@*"/> > <xsl:apply-templates select="node()"> > <xsl:with-param name="parentworkid" select="$workid"/> > <xsl:with-param name="appearance" > select="$appearance"/> > </xsl:apply-templates> > </xsl:element> > </xsl:when> > <xsl:otherwise> > <xsl:element name="{local-name()}"> > <xsl:apply-templates select="@*"/> > <xsl:apply-templates select="node()"> > <xsl:with-param name="parentworkid" select="$workid"/> > <xsl:with-param name="appearance" > select="$appearance"/> > </xsl:apply-templates> > </xsl:element> > </xsl:otherwise> > </xsl:choose> > </xsl:template> > > I have successfully tested this with Firefox (Firefox is not anymore my > default browser because of too many conformance, performance and freeze > issues...). > > Thank you for your feedback! > > --Alain > > > Le 19/01/2016 14:11, Tim Thompson a écrit : > > Alain, > > I am hoping to do some work with XForms and SVG and have been looking at > the current XSLTForms SVG examples. I noticed that, since rev. 595 of > XSLTForms, none of the SVG examples work in Firefox. The reason seems to be > the changes made to the fallback identity template in xsltforms.xsl. > > In the latest revision, if lines 1203-1228[1] are reverted back to the > template used prior to rev. 595, then the SVG examples will work in Firefox: > > <xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > match="node()|@*" priority="-2"> > <xsl:param name="appearance" select="@appearance"/> > <xsl:param name="parentworkid"/> > <xsl:param name="workid" > select="concat(position(),'_',$parentworkid)"/> > <xsl:copy> > <xsl:apply-templates select="@*"/> > <xsl:apply-templates select="node()"> > <xsl:with-param name="parentworkid" select="$workid"/> > <xsl:with-param name="appearance" select="$appearance"/> > </xsl:apply-templates> > </xsl:copy> > </xsl:template> > > Is there a reason not to use this more generic template? I tested on a > range of browsers and did not notice any immediate issues. > > Thanks again! > Tim > > [1] > https://github.com/AlainCouthures/xsltforms/blob/master/build/xsltforms.xsl#L1203 > > > -- > Tim A. Thompson > Metadata Librarian (Spanish/Portuguese Specialty) > Princeton University Library > > > |
|
From: Tim T. <tim...@gm...> - 2016-01-25 03:54:29
|
Using your patch for xsltforms.xsl, I'm running into another SVG issue. I have a graphic that includes a rectangle with a gradient scale. The <rect> element has a @style attribute with a relative reference to the <linearGradient> element where the gradient is defined. It looks like this: <rect style="fill:url(#linearGradient5615);fill-opacity:1;stroke:#000000;stroke-width:1.00722218;stroke-opacity:1" id="rect5607" width="289.07648" height="39.794155" x="801.64746" y="649.0152" /> When I try to load the image in a page with XSLTForms, the gradient does not render. However, if I revert to the old version of the xsltforms.xsl identity template, it does render. Any idea why the relative URL reference in the SVG is not working? This seems to be the case for both Chrome and Firefox. You can see the issue here: http://timathom.github.io/florentine.xhtml And the original image, with properly rendered gradient, here: http://timathom.github.io/img/florentine.svg Thanks again! Tim -- Tim A. Thompson Metadata Librarian (Spanish/Portuguese Specialty) Princeton University Library On Tue, Jan 19, 2016 at 1:08 PM, Alain Couthures < ala...@ag...> wrote: > Tim, > > Thank you for pointing at this issue! > > XSLTForms stylesheet has to deal with namespaces: the best approach for > browsers appears to deliver no namespace for HTML. Using <xsl:copy> is not > a good solution and using <xsl:element> and <xsl:attribute> allows to > remove the XHTML namespace. > > BTW, with the previous template, Saxon was complaining that attributes > cannot have attributes... > > So, I prefer improve the current templates with non-HTML namespaces > support, such as SVG, at least for elements: > > <xsl:template match="*" priority="-2" xmlns:xhtml= > "http://www.w3.org/1999/xhtml" <http://www.w3.org/1999/xhtml> xmlns:xsl= > "http://www.w3.org/1999/XSL/Transform" > <http://www.w3.org/1999/XSL/Transform>> > <xsl:param name="appearance" select="@appearance"/> > <xsl:param name="parentworkid"/> > <xsl:param name="workid" > select="concat(position(),'_',$parentworkid)"/> > <xsl:choose> > <xsl:when test="namespace-uri() != '' and namespace-uri() != ' > http://www.w3.org/1999/xhtml'"> > <xsl:element name="{local-name()}" > namespace="{namespace-uri()}"> > <xsl:apply-templates select="@*"/> > <xsl:apply-templates select="node()"> > <xsl:with-param name="parentworkid" select="$workid"/> > <xsl:with-param name="appearance" > select="$appearance"/> > </xsl:apply-templates> > </xsl:element> > </xsl:when> > <xsl:otherwise> > <xsl:element name="{local-name()}"> > <xsl:apply-templates select="@*"/> > <xsl:apply-templates select="node()"> > <xsl:with-param name="parentworkid" select="$workid"/> > <xsl:with-param name="appearance" > select="$appearance"/> > </xsl:apply-templates> > </xsl:element> > </xsl:otherwise> > </xsl:choose> > </xsl:template> > > I have successfully tested this with Firefox (Firefox is not anymore my > default browser because of too many conformance, performance and freeze > issues...). > > Thank you for your feedback! > > --Alain > > > Le 19/01/2016 14:11, Tim Thompson a écrit : > > Alain, > > I am hoping to do some work with XForms and SVG and have been looking at > the current XSLTForms SVG examples. I noticed that, since rev. 595 of > XSLTForms, none of the SVG examples work in Firefox. The reason seems to be > the changes made to the fallback identity template in xsltforms.xsl. > > In the latest revision, if lines 1203-1228[1] are reverted back to the > template used prior to rev. 595, then the SVG examples will work in Firefox: > > <xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > match="node()|@*" priority="-2"> > <xsl:param name="appearance" select="@appearance"/> > <xsl:param name="parentworkid"/> > <xsl:param name="workid" > select="concat(position(),'_',$parentworkid)"/> > <xsl:copy> > <xsl:apply-templates select="@*"/> > <xsl:apply-templates select="node()"> > <xsl:with-param name="parentworkid" select="$workid"/> > <xsl:with-param name="appearance" select="$appearance"/> > </xsl:apply-templates> > </xsl:copy> > </xsl:template> > > Is there a reason not to use this more generic template? I tested on a > range of browsers and did not notice any immediate issues. > > Thanks again! > Tim > > [1] > https://github.com/AlainCouthures/xsltforms/blob/master/build/xsltforms.xsl#L1203 > > > -- > Tim A. Thompson > Metadata Librarian (Spanish/Portuguese Specialty) > Princeton University Library > > > |
|
From: Alain C. <ala...@ag...> - 2016-01-25 18:54:24
|
Tim, This is a tricky issue because everything sounds OK from the debugger point of view. Happily, changing the identity template for attributes just into "<xsl:copy/>" instead of "<xsl:attribute..." appears to be working for this testcase. Thank you for your feedback! Alain Le 25/01/2016 04:53, Tim Thompson a écrit : > Using your patch for xsltforms.xsl, I'm running into another SVG > issue. I have a graphic that includes a rectangle with a gradient > scale. The <rect> element has a @style attribute with a relative > reference to the <linearGradient> element where the gradient is > defined. It looks like this: > > <rect > style="fill:url(#linearGradient5615);fill-opacity:1;stroke:#000000;stroke-width:1.00722218;stroke-opacity:1" > id="rect5607" width="289.07648" height="39.794155" x="801.64746" > y="649.0152" /> > > When I try to load the image in a page with XSLTForms, the gradient > does not render. However, if I revert to the old version of the > xsltforms.xsl identity template, it does render. Any idea why the > relative URL reference in the SVG is not working? This seems to be the > case for both Chrome and Firefox. > > You can see the issue here: http://timathom.github.io/florentine.xhtml > > And the original image, with properly rendered gradient, here: > http://timathom.github.io/img/florentine.svg > > Thanks again! > Tim > > -- > Tim A. Thompson > Metadata Librarian (Spanish/Portuguese Specialty) > Princeton University Library > > > On Tue, Jan 19, 2016 at 1:08 PM, Alain Couthures > <ala...@ag... <mailto:ala...@ag...>> > wrote: > > Tim, > > Thank you for pointing at this issue! > > XSLTForms stylesheet has to deal with namespaces: the best > approach for browsers appears to deliver no namespace for HTML. > Using <xsl:copy> is not a good solution and using <xsl:element> > and <xsl:attribute> allows to remove the XHTML namespace. > > BTW, with the previous template, Saxon was complaining that > attributes cannot have attributes... > > So, I prefer improve the current templates with non-HTML > namespaces support, such as SVG, at least for elements: > > <xsl:template match="*" priority="-2" > xmlns:xhtml="http://www.w3.org/1999/xhtml" > <http://www.w3.org/1999/xhtml> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <http://www.w3.org/1999/XSL/Transform>> > <xsl:param name="appearance" select="@appearance"/> > <xsl:param name="parentworkid"/> > <xsl:param name="workid" > select="concat(position(),'_',$parentworkid)"/> > <xsl:choose> > <xsl:when test="namespace-uri() != '' and namespace-uri() > != 'http://www.w3.org/1999/xhtml'"> > <xsl:element name="{local-name()}" > namespace="{namespace-uri()}"> > <xsl:apply-templates select="@*"/> > <xsl:apply-templates select="node()"> > <xsl:with-param name="parentworkid" > select="$workid"/> > <xsl:with-param name="appearance" > select="$appearance"/> > </xsl:apply-templates> > </xsl:element> > </xsl:when> > <xsl:otherwise> > <xsl:element name="{local-name()}"> > <xsl:apply-templates select="@*"/> > <xsl:apply-templates select="node()"> > <xsl:with-param name="parentworkid" > select="$workid"/> > <xsl:with-param name="appearance" > select="$appearance"/> > </xsl:apply-templates> > </xsl:element> > </xsl:otherwise> > </xsl:choose> > </xsl:template> > > I have successfully tested this with Firefox (Firefox is not > anymore my default browser because of too many conformance, > performance and freeze issues...). > > Thank you for your feedback! > > --Alain > > > Le 19/01/2016 14:11, Tim Thompson a écrit : >> Alain, >> >> I am hoping to do some work with XForms and SVG and have been >> looking at the current XSLTForms SVG examples. I noticed that, >> since rev. 595 of XSLTForms, none of the SVG examples work in >> Firefox. The reason seems to be the changes made to the fallback >> identity template in xsltforms.xsl. >> >> In the latest revision, if lines 1203-1228[1] are reverted back >> to the template used prior to rev. 595, then the SVG examples >> will work in Firefox: >> >> <xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >> match="node()|@*" priority="-2"> >> <xsl:param name="appearance" select="@appearance"/> >> <xsl:param name="parentworkid"/> >> <xsl:param name="workid" >> select="concat(position(),'_',$parentworkid)"/> >> <xsl:copy> >> <xsl:apply-templates select="@*"/> >> <xsl:apply-templates select="node()"> >> <xsl:with-param name="parentworkid" select="$workid"/> >> <xsl:with-param name="appearance" select="$appearance"/> >> </xsl:apply-templates> >> </xsl:copy> >> </xsl:template> >> >> Is there a reason not to use this more generic template? I tested >> on a range of browsers and did not notice any immediate issues. >> >> Thanks again! >> Tim >> >> [1] >> https://github.com/AlainCouthures/xsltforms/blob/master/build/xsltforms.xsl#L1203 >> >> >> -- >> Tim A. Thompson >> Metadata Librarian (Spanish/Portuguese Specialty) >> Princeton University Library >> > > |
|
From: Tim T. <tim...@gm...> - 2016-01-25 21:04:35
|
Thanks, Alain. That seems to work for me too, cross-browser. Regards, Tim -- Tim A. Thompson Metadata Librarian (Spanish/Portuguese Specialty) Princeton University Library <ta...@pr...> On Mon, Jan 25, 2016 at 1:54 PM, Alain Couthures < ala...@ag...> wrote: > Tim, > > This is a tricky issue because everything sounds OK from the debugger > point of view. > > Happily, changing the identity template for attributes just into > "<xsl:copy/>" instead of "<xsl:attribute..." appears to be working for this > testcase. > > Thank you for your feedback! > > Alain > > > Le 25/01/2016 04:53, Tim Thompson a écrit : > > Using your patch for xsltforms.xsl, I'm running into another SVG issue. I > have a graphic that includes a rectangle with a gradient scale. The <rect> > element has a @style attribute with a relative reference to the > <linearGradient> element where the gradient is defined. It looks like this: > > <rect > style="fill:url(#linearGradient5615);fill-opacity:1;stroke:#000000;stroke-width:1.00722218;stroke-opacity:1" > id="rect5607" width="289.07648" height="39.794155" x="801.64746" > y="649.0152" /> > > When I try to load the image in a page with XSLTForms, the gradient does > not render. However, if I revert to the old version of the xsltforms.xsl > identity template, it does render. Any idea why the relative URL reference > in the SVG is not working? This seems to be the case for both Chrome and > Firefox. > > You can see the issue here: <http://timathom.github.io/florentine.xhtml> > http://timathom.github.io/florentine.xhtml > > And the original image, with properly rendered gradient, here: > http://timathom.github.io/img/florentine.svg > > Thanks again! > Tim > > -- > Tim A. Thompson > Metadata Librarian (Spanish/Portuguese Specialty) > Princeton University Library > > > On Tue, Jan 19, 2016 at 1:08 PM, Alain Couthures < > <ala...@ag...>ala...@ag...> wrote: > >> Tim, >> >> Thank you for pointing at this issue! >> >> XSLTForms stylesheet has to deal with namespaces: the best approach for >> browsers appears to deliver no namespace for HTML. Using <xsl:copy> is not >> a good solution and using <xsl:element> and <xsl:attribute> allows to >> remove the XHTML namespace. >> >> BTW, with the previous template, Saxon was complaining that attributes >> cannot have attributes... >> >> So, I prefer improve the current templates with non-HTML namespaces >> support, such as SVG, at least for elements: >> >> <xsl:template match="*" priority="-2" xmlns:xhtml= >> "http://www.w3.org/1999/xhtml" <http://www.w3.org/1999/xhtml> xmlns:xsl= >> "http://www.w3.org/1999/XSL/Transform" >> <http://www.w3.org/1999/XSL/Transform>> >> <xsl:param name="appearance" select="@appearance"/> >> <xsl:param name="parentworkid"/> >> <xsl:param name="workid" >> select="concat(position(),'_',$parentworkid)"/> >> <xsl:choose> >> <xsl:when test="namespace-uri() != '' and namespace-uri() != ' >> http://www.w3.org/1999/xhtml'"> >> <xsl:element name="{local-name()}" >> namespace="{namespace-uri()}"> >> <xsl:apply-templates select="@*"/> >> <xsl:apply-templates select="node()"> >> <xsl:with-param name="parentworkid" select="$workid"/> >> <xsl:with-param name="appearance" >> select="$appearance"/> >> </xsl:apply-templates> >> </xsl:element> >> </xsl:when> >> <xsl:otherwise> >> <xsl:element name="{local-name()}"> >> <xsl:apply-templates select="@*"/> >> <xsl:apply-templates select="node()"> >> <xsl:with-param name="parentworkid" select="$workid"/> >> <xsl:with-param name="appearance" >> select="$appearance"/> >> </xsl:apply-templates> >> </xsl:element> >> </xsl:otherwise> >> </xsl:choose> >> </xsl:template> >> >> I have successfully tested this with Firefox (Firefox is not anymore my >> default browser because of too many conformance, performance and freeze >> issues...). >> >> Thank you for your feedback! >> >> --Alain >> >> >> Le 19/01/2016 14:11, Tim Thompson a écrit : >> >> Alain, >> >> I am hoping to do some work with XForms and SVG and have been looking at >> the current XSLTForms SVG examples. I noticed that, since rev. 595 of >> XSLTForms, none of the SVG examples work in Firefox. The reason seems to be >> the changes made to the fallback identity template in xsltforms.xsl. >> >> In the latest revision, if lines 1203-1228[1] are reverted back to the >> template used prior to rev. 595, then the SVG examples will work in Firefox: >> >> <xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >> match="node()|@*" priority="-2"> >> <xsl:param name="appearance" select="@appearance"/> >> <xsl:param name="parentworkid"/> >> <xsl:param name="workid" >> select="concat(position(),'_',$parentworkid)"/> >> <xsl:copy> >> <xsl:apply-templates select="@*"/> >> <xsl:apply-templates select="node()"> >> <xsl:with-param name="parentworkid" select="$workid"/> >> <xsl:with-param name="appearance" select="$appearance"/> >> </xsl:apply-templates> >> </xsl:copy> >> </xsl:template> >> >> Is there a reason not to use this more generic template? I tested on a >> range of browsers and did not notice any immediate issues. >> >> Thanks again! >> Tim >> >> [1] >> <https://github.com/AlainCouthures/xsltforms/blob/master/build/xsltforms.xsl#L1203> >> https://github.com/AlainCouthures/xsltforms/blob/master/build/xsltforms.xsl#L1203 >> >> >> -- >> Tim A. Thompson >> Metadata Librarian (Spanish/Portuguese Specialty) >> Princeton University Library >> >> >> > > |