XML Elves

XML Elves

<community>of XML and SVG Developers</community>


Saving svg

This is a discussion on Saving svg within the SVG Questions forums, part of the SVG Forums category; Hello everyone, i 'm drawing some svg's Shape dynamically inside a <g id="Dessiner">. My problem is that when i am ...


Go Back   XML Elves > SVG Forums > SVG Questions

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Notices


Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-08-2004, 07:50 AM
Seb
Guest
 
Posts: n/a
Default Saving svg

Hello everyone,

i 'm drawing some svg's Shape dynamically inside a <g id="Dessiner">. My problem is that when i am recording the shapes i need to do it in a group.Otherwise when i try to open this file only the first shape appear. Does anyone know how to record my file without adding a group? When i open my file i would like <g id="Dessiner"> to be the first parent.

Thanks in advance, s?bastien.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-08-2004, 09:01 AM
Anonymous
Guest
 
Posts: n/a
Default Re: Saving svg

Quote:
Originally Posted by Seb
Hello everyone,

i 'm drawing some svg's Shape dynamically inside a <g id="Dessiner">. My problem is that when i am recording the shapes i need to do it in a group.Otherwise when i try to open this file only the first shape appear. Does anyone know how to record my file without adding a group? When i open my file i would like <g id="Dessiner"> to be the first parent.

Thanks in advance, s?bastien.
You can record your shapes in a group ( I think that you use ASV 6 ... to get this problem ) and when you open your file, after parsing content, you add only childs to your group "Dessiner". You will retrieve your shapes as childs of "Dessiner".

Michel
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-09-2004, 02:08 AM
Seb
Guest
 
Posts: n/a
Default Saving svg

Hello Michel,

No i am not working with asv6 yet. I have tried to do what you told to, but i have difficulties to succeed.Here's my code:

Dess = svgdoc.getElementById("Dessiner");

if(data.success)
{
var Long=data.content.length;
message=data.content.substring(4,Long-4);
//message=data.content.getChildNodes;alert(message);
new_node =parseXML(data.content, document);
Dess.appendChild(new_node);
}

messge is the data.content without the <g> and </g>. That is what i would like , but if i put it instead of data.content; only my first group will appear.

Do you have any idea?

Thanks in advance, s?bastien.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-09-2004, 02:24 AM
Anonymous
Guest
 
Posts: n/a
Default Saving svg

Quote:
Originally Posted by Seb
Dess = svgdoc.getElementById("Dessiner");
if(data.success)
{
var Long=data.content.length;
message=data.content.substring(4,Long-4);
//message=data.content.getChildNodes;alert(message);
new_node =parseXML(data.content, document);
Dess.appendChild(new_node);
}
When you parse, you get many elements and append only first ...
If you parse data.content, you get your group and have to append all childs
You can use that :
if (data.success)
{
var doc_frag = parseXML ( data.content, document);
childs=doc_frag.childNodes
number=childs.length
for (i=0;i<number;i++)
{
child=childs.item(i)
Dess.appendChild (child)
}
}

Michel
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-09-2004, 02:51 AM
Seb
Guest
 
Posts: n/a
Default Saving svg

Michel, it is not working yet. When i do an alert on my clipboard content, i can see two <g> and </g>.

here is my code for the clipboard and your code to read the file.

function Clipboard()
{
shapes = Dess.childNodes;
Compteur = shapes.length;

if(top.clipboardData)
{
NewSVG ="";

for(i=0; i<Compteur; i++)
{
NewSVG +=printNode(shapes.item(i));
}

NewSVG='<g>'+NewSVG+'</g>';
top .clipboardData.setData("Text", NewSVG);
alert(NewSVG);
}
else alert("Vous devez creer des objets pour pouvoir utiliser cette fonction");
}

function Importer(reponse)
{
//reponse=prompt("Choisissez un fichier");
getURL("Dossier Perso\\"+reponse+".svg", fileLoaded);
}

function fileLoaded(data)
{
if(data.success)
{

new_node =parseXML(data.content, document);

var nouv=new_node.childNodes;
compte=nouv.length;

for(i=0; i<compte; i++)
{
child=nouv.item(i);
Dess.appendChild(child);
}
}
else
{
alert('Loading has failed');
}
}

Thanks, a plus s?bastien.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 03-09-2004, 03:22 AM
Anonymous
Guest
 
Posts: n/a
Default Saving svg

Quote:
Originally Posted by Seb
function Clipboard()
{
shapes = Dess.childNodes;
Compteur = shapes.length;

if(top.clipboardData)
{
NewSVG ="";
for(i=0; i<Compteur; i++)
{
NewSVG +=printNode(shapes.item(i));
}
NewSVG='<g>'+NewSVG+'</g>';
top .clipboardData.setData("Text", NewSVG);
alert(NewSVG);
}
else alert("Vous devez creer des objets pour pouvoir utiliser cette fonction");
}
To save your group, make only :

function Clipboard()
{
if(top.clipboardData)
{
NewSVG=printNode(Dess)
alert(NewSVG);
}
else alert("Vous devez creer des objets pour pouvoir utiliser cette fonction");
}

Michel
Michel
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 03-09-2004, 03:35 AM
Seb
Guest
 
Posts: n/a
Default Saving svg

The problem now is that everytime i am recording on a saved file, i am saving an other time <g id="Dessiner">.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 03-09-2004, 04:07 AM
Anonymous
Guest
 
Posts: n/a
Default Saving svg

Quote:
Originally Posted by Seb
The problem now is that everytime i am recording on a saved file, i am saving an other time <g id="Dessiner">.
Where is the problem ?
Change id or remove it before saving.
When you record on existing file, arrange your objects with server language.

Michel
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 03-09-2004, 06:41 AM
Seb
Guest
 
Posts: n/a
Default Saving svg

In fact i am arranging everything in my function Clipboard, not on the server side, and it seems to work.

s?bastien
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
saving, svg


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -6. The time now is 02:12 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0

Printer Inks
Get high quality printer inks from Prink. We have over 50,000 ink cartridges in stock. Free UK delivery on compatible ink cartridges for your printer.

epson ink cartridges
Discount Epson ink Cartridges from Internet Ink. Some of the cheapest Ink cartridges online.

HARD DISK DRIVE DATA RECOVERY CHESHIRE
Professional, prompt and cost effective hard disk drive data recovery. Click above!

ink cartridges Free UK Delivery on ink cartridges such as Canon, Dell, Epson, hp & Lexmark.

1 2 3 4 5 6 7 8 9 10