Link to home
Start Free TrialLog in
Avatar of maverick1611
maverick1611

asked on

edit xml from the browser using xsl !!

Hi,
I am trying to do the following.
I have a simple xml file. An xsl transforms the values of the nodes into text boxes and shows it in as HTML. I have added the code for the xsl too at the bottom.
Now I want to allow editing the values in the text box using the browser. How do I do that ? Currently if I change the values in the text box, it shows the new values in the browser but even if I save this view as a new HTML file, I still get the same old values in the xml file. I want to be able make changes to the xml and save them. I know it can be done using ASP etc but i dont want to use ASP. The requirement is that I send such an xml file to some one by email who can open it and it should appear as a form to them which they can edit or fill out and save it and send it back to me over email as an attachment.
Thanks in advance.
mav.

XML File:EmpAttrTextBoxPull1.xml

<?xml version='1.0' encoding='utf-8' ?>
<?xml-stylesheet type="text/xsl" href="EmpAttrTextBoxPull1.xsl"?>
<employees>
      <employee>
            <employeename type="INPUT" desc="Employee Name" size="30">John Doe</employeename>
            <hourlyrate type="input" desc="Hourly Rate" size="12">5000</hourlyrate>
            <department type="input" desc="Department" size="20">ABC Inc</department>
            <nativelanguage type="input" desc="Spoken Language" size="25">English</nativelanguage>>
            <primarylanguage type="input" desc="Programming Language" size="25">All</primarylanguage>
      </employee>
</employees>


XSL file: EmpAttrTextBoxPull1.xsl

<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html"/>
      
      <xsl:template match="/">

            
            <xsl:for-each select="/employees/employee">
                  <!-- The following for-each loop will iterate through all of the child elements
                 of employee -->
                  <xsl:for-each select="*">
                        <xsl:value-of select="@desc"/>
                        
                        <!-- Note: Curly braces are a shorthand for the value of an attribute -->
                        <xsl:element name="{@type}">

                              <!-- Set the Size of the textbox -->
                              <xsl:attribute name="size">
                                    <xsl:value-of select="@size"/>
                              </xsl:attribute>

                              <!-- Set the Size of the textbox -->
                              <xsl:attribute name="maxlength">
                                    <xsl:value-of select="@size"/>
                              </xsl:attribute>

                              <!-- Set the value of the text box -->
                              <xsl:attribute name="value">
                                    <xsl:value-of select="text()"/>
                              </xsl:attribute>
                              <br/>
                        </xsl:element>
                  </xsl:for-each>
            </xsl:for-each>
      </xsl:template>
</xsl:stylesheet>
Avatar of MogalManic
MogalManic
Flag of United States of America image

You will have to some sort of form submital.  Include a <form> tag in the XSL and a submit button.  The action of the form is set for 'javaScript:SaveData()'

Write a saveData javascript that uses MSXML and takes the form data and writes it back to the XML document.
Avatar of maverick1611
maverick1611

ASKER

Hi,
thanks for the help. I've been able to put a submit button to call a javascript function from it.
The problem now is that I'm not able to write the javascript function to get the new values from the text boxes and save these values back to the xml file. could you please show me some sample code that does this.
thanks a lot .
mav.
Hi,
I tried a simple javascript to save the xml file, but it keeps giving me errors saying permission denied. I am wondering if it is even possible to save an xml file using javascript on the local machine since java script is client side and the browser wont let it have permission to write to client machines.

is there a work around for this . Please let me know.
Thanks,
mav
That should work.  Could you send what you have so far?

ASKER CERTIFIED SOLUTION
Avatar of MogalManic
MogalManic
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm sorry to say that your requirements aren't feasible.  Any e-mail client worth anything is explicitly designed prohibit what you've described.  There's no avoiding developing an application to receive the form results in ASP/JSP/Whatever, which you include in the action field of your opening form tag.
Well thanks MogalManic,
I worked a bit on the security issues and now I use an ActiveXObject script to save the xml file on the client. The browser ofcourse gives me a warniong before it can run the script but it serves my purpose. one way of avoiding the warning messagfe would be to get a digital signature which i'll worry about later.
I'll give you 100 points none the less for pointing me in the right direction.
thanks.
mav