XML Elves

XML Elves

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


To edit and save a svg file

This is a discussion on To edit and save a svg file within the SVG Questions forums, part of the SVG Forums category; We are doing an Id card designing site using php and svg..we are able to edit the contents of svg ...


Go Back   XML Elves > SVG Forums > SVG Questions

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



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-31-2009, 10:52 PM
Junior Member
 
Join Date: May 2009
Location: Chennai
Posts: 1
Default To edit and save a svg file

We are doing an Id card designing site using php and svg..we are able to edit the contents of svg using javascript and php but dont know how to save those edited data.can anyone help us???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 10-05-2009, 06:12 AM
Junior Member
 
Join Date: Oct 2009
Posts: 4
Default

I have this very same question. I'm modifying svg-file with javascript and I need to save the updates. No idea how, though. I've search through internet with no luck. I hope someone could show me a way to continue my search - or even better: tell the solution!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-05-2009, 07:28 AM
Junior Member
 
Join Date: Oct 2009
Posts: 5
Default RE: To edit and save a svg file

One way might be to store the changes made in a database and reference these changes against a unique user login/pword

so assuming you have a database you are generating the svg content from, and the user changes the id=name text tag content from "name goes here" to "john smith" once the user submits the form use script to detect for changes and send any differences/changes to the database, I would imagine this could also be done on the fly rather than all at once at the end.

when the svg is called up again based on the above user login get the php to output saved content(if there is any) rather than original content.

Obviously the more complex you make the changes the larger the task you will have but once setup should do the trick.

Unfortunately I do not have an example set up but I am pretty sure it would work and if i do have the time at some stage might be able to put something simple together

I hope this helps or at least sends you in a direction that might get you a working solution
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-05-2009, 08:45 AM
Junior Member
 
Join Date: Oct 2009
Posts: 4
Default

Hmm, didn't think it that way. Thanks! I have to look if that's gonna help me.

Is there any way I could see "evt.target.ownerDocument" as a text? That is the svg document I'm altering with javascript. When I add there, lets say, a circle, it won't appear on my .svg file but exists in that evt.target.ownerDocument. If I try to print evt.target.ownerDocument, it just gives "[object SVGDocument]".
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 10-05-2009, 01:40 PM
Junior Member
 
Join Date: Oct 2009
Posts: 5
Default RE: To edit and save a svg file

Danae

I'm not too sure I follow you, I think what you are after is a simple save to text file once the user has carried out changes. I am not sure this is possible but someone with more experience might be able to confirm this.

How is the user generating the circle object? I would suggest at this stage (when circle is generated) capture the object and send to database appending an id value to it.

So in the code below which is from carto:net - Manipulating SVG Documents Using ECMAScript (Javascript) and the DOM where I have added the alert to construct the object, replace the alert with a send to the database, then when you generate the svg with php/asp simply call the DB content for that group and populate the group with the saved data

Again - not sure this is exactly what you are after but might give you some ideas

Code:
<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
    <!ATTLIST svg xmlns:a3 CDATA #IMPLIED a3:scriptImplementation CDATA #IMPLIED>
    <!ATTLIST script a3:scriptImplementation CDATA #IMPLIED>
]>
<?AdobeSVGViewer save="snapshot"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:attrib="http://www.carto.net/attrib" viewBox="-20 -20 400 250" id="cont" width="800" height="500">

<script type="text/ecmascript"><![CDATA[
	

    var svgNS = "http://www.w3.org/2000/svg";

    function createRect() {
      var newRect = document.createElementNS(svgNS,"rect");
      newRect.setAttributeNS(null,"width",Math.random() * 100);	
      newRect.setAttributeNS(null,"height",Math.random() * 100);		
      newRect.setAttributeNS(null,"x",Math.random() * 250);		
      newRect.setAttributeNS(null,"y",Math.random() * 180 + 60);	
      newRect.setAttributeNS(null,"fill-opacity",Math.random());		
      var red = Math.round(Math.random() * 255);
      var green = Math.round(Math.random() * 255);
      var blue = Math.round(Math.random() * 255);
      newRect.setAttributeNS(null,"fill","rgb("+ red +","+ green+","+blue+")");
      document.getElementById("firstGroup").appendChild(newRect);
      alert("<rect x='" + newRect.getAttributeNS(null,"x") + " y='" + newRect.getAttributeNS(null,"y") + "'  width='" + newRect.getAttributeNS(null,"width") + "' height='" + newRect.getAttributeNS(null,"height") + "' fill='" + newRect.getAttributeNS(null,"fill") + "' id='userrect1' />");
    }
    
    	
]]></script>
 
<g id="firstGroup">
  <text x="20" y="30" onclick="createRect()" font-size="13px">Click on this text to create a new rectangle.</text>
</g>

</svg>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 10-12-2009, 03:39 AM
Junior Member
 
Join Date: Oct 2009
Posts: 4
Default

Thanks a lot for your time and effort, but that isn't quite the thing I'd need. Well, I keep looking for a solution (:
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 10-12-2009, 06:22 AM
Junior Member
 
Join Date: Oct 2009
Posts: 5
Default

np good luck!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 10-26-2009, 08:24 AM
Junior Member
 
Join Date: Oct 2009
Posts: 4
Default

Still no luck with this. In XML (PHP) there is a function saveXML(). I'm looking for same function for SVG.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 03-23-2010, 01:57 AM
Junior Member
 
Join Date: Mar 2010
Posts: 1
Default comment

Hay thats good! I know that JavaScript is an object-oriented scripting language used to enable programmatic access to objects within both the client application and other applications. It is primarily used in the form of client-side JavaScript, implemented as an integrated component of the web browser, allowing the development of enhanced user interfaces and dynamic websites. JavaScript is a dialect of the ECMAScript standard and is characterized as a dynamic, weakly typed, prototype-based language with first-class functions. JavaScript was influenced by many languages and was designed to look like Java, but to be easier for non-programmers to work with.
__________________
botham

Last edited by botham; 03-23-2010 at 01:57 AM.. Reason: problem
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
edit, file, save, 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 01:54 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.0 RC3

Data recovery service
Data Clinic's data recovery success rate is proven by consistent success. Click here for more!


1 2 3 4 5 6 7 8 9 10 11 12 13 14