You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Urs Hensler <ur...@access.unizh.ch> on 2005/01/11 13:57:51 UTC

createElementNS(null, 'svg') - Bug?

Hi,

I don't speak english very well. So, I hope you understand my question.

I modified the sample file "test/spec/scripting/nestedsvg.svg" (see 
below). The nested svg-elemet is now created on the fly in the 
ecmascript. In the original file the svg-element was part of the <defs> 
section.

When I load the file in Batik the rect is NOT displayed. In the Adobe 
SVG Plugin it IS displayed. Is this a bug? Or is my ecmascript not 
correct?

Thank you in advance,
Urs


<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      id="body" width="450" height="500" viewBox="0 0 450 500">

     <title>nested svg element</title>

     <script type="text/ecmascript"><![CDATA[
         function build(evt) {
                 var g = evt.target;
                 //var svg = g.ownerDocument.getElementById('svg');
                 var svg = g.ownerDocument.createElementNS(null, 'svg');
                 svg.setAttributeNS(null, 'id', 'svg_test');
				svg.setAttributeNS(null, 'width', '450');
				svg.setAttributeNS(null, 'height', '500');
				svg.setAttributeNS(null, 'viewBox', '0 0 450 500');
                 var rect = g.ownerDocument.createElementNS(null, 
'rect');
                 rect.setAttributeNS(null, 'id', 'rect_test');
                 rect.setAttributeNS(null, 'x', '10%');
                 rect.setAttributeNS(null, 'y', '10%');
				rect.setAttributeNS(null, 'width', '80%');
				rect.setAttributeNS(null, 'height', '80%');
				rect.setAttributeNS(null, 'style', 'fill:crimson');
				svg.appendChild(rect);
                 g.appendChild(svg);
         }

     ]]></script>

<g>
     <g onload="build(evt)" id="test-content">
     </g>
</g>

</svg>


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: createElementNS(null, 'svg') - Bug?

Posted by Urs Hensler <ur...@access.unizh.ch>.
Hi Thomas,

Thank you for the hint. Now, it works.



Am 11.01.2005 um 16:31 schrieb Thomas DeWeese:

> Hi Urs,
>
>    Please take the time to read the FAQ:
>
> 	http://xml.apache.org/batik/faqs.html#faq-23
>
> Urs Hensler wrote:
>
>> Hi,
>> I don't speak english very well. So, I hope you understand my 
>> question.
>> I modified the sample file "test/spec/scripting/nestedsvg.svg" (see 
>> below). The nested svg-elemet is now created on the fly in the 
>> ecmascript. In the original file the svg-element was part of the 
>> <defs> section.
>> When I load the file in Batik the rect is NOT displayed. In the Adobe 
>> SVG Plugin it IS displayed. Is this a bug? Or is my ecmascript not 
>> correct?
>> Thank you in advance,
>> Urs
>> <?xml version="1.0" standalone="no"?>
>> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
>> "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
>> <svg xmlns="http://www.w3.org/2000/svg"
>>      xmlns:xlink="http://www.w3.org/1999/xlink"
>>      id="body" width="450" height="500" viewBox="0 0 450 500">
>>     <title>nested svg element</title>
>>     <script type="text/ecmascript"><![CDATA[
>>         function build(evt) {
>>                 var g = evt.target;
>>                 //var svg = g.ownerDocument.getElementById('svg');
>>                 var svg = g.ownerDocument.createElementNS(null, 
>> 'svg');
>>                 svg.setAttributeNS(null, 'id', 'svg_test');
>>                 svg.setAttributeNS(null, 'width', '450');
>>                 svg.setAttributeNS(null, 'height', '500');
>>                 svg.setAttributeNS(null, 'viewBox', '0 0 450 500');
>>                 var rect = g.ownerDocument.createElementNS(null, 
>> 'rect');
>>                 rect.setAttributeNS(null, 'id', 'rect_test');
>>                 rect.setAttributeNS(null, 'x', '10%');
>>                 rect.setAttributeNS(null, 'y', '10%');
>>                 rect.setAttributeNS(null, 'width', '80%');
>>                 rect.setAttributeNS(null, 'height', '80%');
>>                 rect.setAttributeNS(null, 'style', 'fill:crimson');
>>                 svg.appendChild(rect);
>>                 g.appendChild(svg);
>>         }
>>     ]]></script>
>> <g>
>>     <g onload="build(evt)" id="test-content">
>>     </g>
>> </g>
>> </svg>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>> For additional commands, e-mail: batik-users-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: createElementNS(null, 'svg') - Bug?

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Urs,

    Please take the time to read the FAQ:

	http://xml.apache.org/batik/faqs.html#faq-23

Urs Hensler wrote:

> Hi,
> 
> I don't speak english very well. So, I hope you understand my question.
> 
> I modified the sample file "test/spec/scripting/nestedsvg.svg" (see 
> below). The nested svg-elemet is now created on the fly in the 
> ecmascript. In the original file the svg-element was part of the <defs> 
> section.
> 
> When I load the file in Batik the rect is NOT displayed. In the Adobe 
> SVG Plugin it IS displayed. Is this a bug? Or is my ecmascript not correct?
> 
> Thank you in advance,
> Urs
> 
> 
> <?xml version="1.0" standalone="no"?>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
> "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
> 
> <svg xmlns="http://www.w3.org/2000/svg"
>      xmlns:xlink="http://www.w3.org/1999/xlink"
>      id="body" width="450" height="500" viewBox="0 0 450 500">
> 
>     <title>nested svg element</title>
> 
>     <script type="text/ecmascript"><![CDATA[
>         function build(evt) {
>                 var g = evt.target;
>                 //var svg = g.ownerDocument.getElementById('svg');
>                 var svg = g.ownerDocument.createElementNS(null, 'svg');
>                 svg.setAttributeNS(null, 'id', 'svg_test');
>                 svg.setAttributeNS(null, 'width', '450');
>                 svg.setAttributeNS(null, 'height', '500');
>                 svg.setAttributeNS(null, 'viewBox', '0 0 450 500');
>                 var rect = g.ownerDocument.createElementNS(null, 'rect');
>                 rect.setAttributeNS(null, 'id', 'rect_test');
>                 rect.setAttributeNS(null, 'x', '10%');
>                 rect.setAttributeNS(null, 'y', '10%');
>                 rect.setAttributeNS(null, 'width', '80%');
>                 rect.setAttributeNS(null, 'height', '80%');
>                 rect.setAttributeNS(null, 'style', 'fill:crimson');
>                 svg.appendChild(rect);
>                 g.appendChild(svg);
>         }
> 
>     ]]></script>
> 
> <g>
>     <g onload="build(evt)" id="test-content">
>     </g>
> </g>
> 
> </svg>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org