This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Write to XML file using XSL


Jaimin,
This is the second time you have asked a question like this today and the
answer is there is no simple answer. There are no simple readymade solutions
and no functions in JavaScript that will do it.
There are however many different ways to solve this problem. One solution
I'll outline here.
Using this xml
<form>
	<input>xxx</input>
	<input>yyy</input>
	<input>zzz</input>
</form>
In your XSL transform write a template for the <input> tag that outputs your
html <INPUT> box. Give the <INPUT> box an attribute xpath that contains a
unique path to the xml that generated it. Something like

<xsl:template match="input">
	<INPUT onchange="updateXML(this)">
		<xsl:attribute name="value"><xsl:value-of select="text()
/></xsl:attribute>
		<xsl:attribute name="xpath"><xsl:call-template name="getXpath"
/></xsl:attribute>
	</INPUT>
</xsl:template>
<xsl:template name="getXpath">
	<!-- can't remember this off the top of my head but it is in the xsl
faq -->
</xsl:template>

You then need a JavaScript function that will update the xml when the input
box changes. Something like this will do.

function updateXML(obj){
	var x = document.XMLDocument;
	var n = x.selectSingleNode(obj.xpath);
	n.nodeValue = obj.value;
}

Then you need to save the xml to a file. There are many ways to do this too
depending on where you want the file to end up. Check out
document.XMLDocument.save("filename") and XMLHTTP.open()/send()

Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


>-----Original Message-----
>From: owner-xsl-list@mulberrytech.com
>[mailto:owner-xsl-list@mulberrytech.com]On Behalf Of
>JaiminSoni123@aol.com
>Sent: 17 August 2000 20:36
>To: xsl-list@mulberrytech.com
>Subject: Write to XML file using XSL
>
>
>Hi Guys,
>       Does anyone know how to write to an xml file using the XSL
>stylesheet that it calls??  In other words, I have and xsl which
>produces textboxes in several places in the xml document.  The
>value a user enters in to these text boxes has to go in the xml
>file and add to or update the file.  Does any one know how i could
>do this.  Is there a javascript function or something that I could
>use to get this functionality??  Please let me know soon.  any
>help would be greatly appreciated.  Thanks.
>
>Jaimin.
>
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]