DOM SVG to String ... [Archive] - XML Elves

DOM SVG to String ...

Cast
06-29-2004, 01:03 PM
Hi ... I need to show a SVG document just in text ... I want to serialize it in a variable String ... Im using the java DOM API or Batik ... Does anybody know how to do this?


Again and again ... Thanks ...

Anonymous
06-30-2004, 07:49 AM
In fact something as printNode in ASV ?

Michel

freedoms
07-01-2004, 11:25 AM
SVG Replacing APPLETs for WAI purposes:
Part help, part question::

I'm trying to replace my non WAI-compilant horizontal text scrolling
APPLET with SVG. So far I have got as far as:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">;
<svg width="300" height="300" version="1.1"
xmlns="http://www.w3.org/2000/svg">;
<g transform="translate(100,100)">
<text id="TextElement" x="0" y="0"
style="font-family:sans-serif;font-size:24;
font-weight:bold">
Scrolling text, but no concept of automatic length... yet!
<animateMotion path="M 250 0 L -250 0" dur="4s" fill="freeze"
repeatCount="indefinite" />
</text>
</g>
</svg>

(Which is good enough for non-animated text if you omit the <animateMotion ... /> tag.)

It needs to replace announcement "marquee" effect at http://Freedoms.4t.com

How do I grab the DOM property of the x-length of the text, and plunk it into the animateMotion path?

Anonymous
07-01-2004, 12:35 PM
How do I grab the DOM property of the x-length of the text, and plunk it into the animateMotion path?

You can use getComputedTextLength() to know length of your text

You can also use textPath and animate startOffset attribute.

Michel

Examples at
http://pilat.free.fr/english/animer/index.htm

freedoms
07-27-2004, 12:48 PM
useage::

Thank for that. I have been experimenting.

As far as I can see this would generate something like:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">;
<svg width="500" height="100" viewBox="0 0 500 100">
<g id='affiche'></g>
<text x="20" y="95" style="font-size:20;fill:black;text-anchor:middle">
Sample
<animate attributeName="x" from="20" to="200" dur="5s"
repeatCount="indefinite"/>
</text>
</svg>

(This example does not work.)
Nonetheless, why can't I have less script and more unchanging SVG, such as:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">;
<svg width="500" height="100" viewBox="0 0 500 100" onload="anime(evt)">
<!--Adapted from Rolling-->
<script><![CDATA[

function anime(evt)
{
svgdoc=evt.getTarget().getOwnerDocument();
objet=svgdoc.getElementById("texte");
longueur=objet.getComputedTextLength();
node=svgdoc.getElementById("scroll");
node.setAttribute("to",-longueur);
}

]]></script>

<rect x="0" y="0" width="500" height="100" fill="yellow" />
<g id="affiche"></g>
<text id=texte x="500" y="90" style="opacity:1;text-anchor:left;
font-size:20;font-family:Verdana;fill:black">Pilat Informatique Educative
vous presente ses meilleurs voeux pour 2002
<animate id="scroll" attributeName="x"
from="500" to="1500" dur="20s" repeatCount="indefinite" />
</text>
</svg>


...Or even:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">;
<svg width="500" height="100" viewBox="0 0 500 100" onload="anime(evt)">
<!--Adapted from Rolling-->

<!-- can I... ? ,>> -->
<rect x="0" y="0" width="500" height="100" fill="yellow" />
<g id="affiche"></g>
<text id=texte x="500" y="90" style="opacity:1;text-anchor:left;
font-size:20;font-family:Verdana;fill:black">Pilat Informatique Educative
vous presente ses meilleurs voeux pour 2002
<animate id="scroll" attributeName="x"
from="500" to="-(evt.getTarget().getOwnerDocument().getElementById ("texte").getComputedTextLength())"
dur="20s" repeatCount="indefinite" />
</text>
</svg>

(Neither of these work either.)


My other experiments have produced this nice Christmas Tree (which is relevant; I am going to use it in conjunction with

scrolling text for seasonal occasions later):

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN"
"http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd">
<svg width="1.575in" height="3.15in"
style="fill-rule:evenodd;fill-opacity:1;stroke-dasharray:none;
stroke-linejoin:miter;stroke-linecap:butt;stroke:none; stroke-opacity:0"
viewBox="90720 -181440 72576 145152">
<g><title>Christmas Tree</title>
<desc>
Generated from by Draw2SVG 0.0.11 (Jan 11 2004)
Attempted to squash alittle.
Basic hierarchical metadata added.
Later to define as a reusable icon.
</desc>
<g style="fill:#558800"><title>Foliage</title>
<path d="M163296 -72576h-72576l36288 -36288l36288 36288z" />
<path d="M99792 -90720h54432l-27216 -54432l-27216 54432z" />
<path d="M108864 -117936h36288l-18144 -63504l-18144 63504z" />
</g>
<g><title>Baubles</title>
<path style="fill:#EEEE00"
d="M127008 -136080c-885 886 -2321 886 -3207 0c-886 -886 -886
-2322 0 -3207c886 -886 2322 -886 3207 0c886 885 886 2321 0 3207z" />
<path style="fill:#FF6000"
d="M136080 -127008c-885 886 -2321 886 -3207 0c-886 -886 -886
-2322 0 -3207c886 -886 2322 -886 3207 0c886 885 886 2321 0 3207z" />
<path style="fill:#EEEE00"
d="M117936 -108864c-885 886 -2321 886 -3207 0c-886 -886 -886
-2322 0 -3207c886 -886 2322 -886 3207 0c886 885 886 2321 0 3207z" />
<path style="fill:#EEEE00"
d="M145152 -99792c-885 886 -2321 886 -3207 0c-886 -886 -886
-2322 0 -3207c886 -886 2322 -886 3207 0c886 885 886 2321 0 3207z" />
<path style="fill:#FF6000"
d="M127008 -90720c-885 886 -2321 886 -3207 0c-886 -886 -886
-2322 0 -3207c886 -886 2322 -886 3207 0c886 885 886 2321 0 3207z" />
<path style="fill:#EEEE00"
d="M145152 -81648c-885 886 -2321 886 -3207 0c-886 -886 -886
-2322 0 -3207c886 -886 2322 -886 3207 0c886 885 886 2321 0 3207z" />
<path style="fill:#EEEEBB"
d="M117936 -81648c-885 886 -2321 886 -3207 0c-886 -886 -886
-2322 0 -3207c886 -886 2322 -886 3207 0c886 885 886 2321 0 3207z" />
<path style="fill:#EEEEBB"
d="M127008 -154224c-885 886 -2321 886 -3207 0c-886 -886 -886
-2322 0 -3207c886 -886 2322 -886 3207 0c886 885 886 2321 0 3207z" />
</g>
<g style="fill:#964343"><title>Trunk & Base</title>
<path d="M108864 -63504h36288l-9072 27216h-18144l-9072 -27216z" />
<path d="M122472 -72576h9072v9072h-9072v-9072z" />
</g>
</g>
</svg>

Should I have <title>Trunk & Base</title> or <title>Trunk & Base</title>
? I tried substituting & within your message, but it was printed literally.

Anonymous
07-27-2004, 03:48 PM
<animate id="scroll" attributeName="x"
from="500" to="-(evt.getTarget().getOwnerDocument().getElementById ("texte").getComputedTextLength())"
dur="20s" repeatCount="indefinite" />

cannot run in SVG 1.1 or even 1.2
to attribute need value and cannot refer to others values.

When you say that examples don't run, do you use Adobe plugin?
In Batik or Corel viewer, animations don't run ...they are not implemented.

Michel

Anonymous
07-28-2004, 11:11 AM
I do use the Adobe plugin, and usually under Ms IE.
I connect through internet cafe's, so I am at the mercy of their varying specifications, although the same variaty can help with validation.

 
Web mp2kmag.com
mapforums.com

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum