Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 6th, 2010, 07:20 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 115
Thanks: 2
Thanked 0 Times in 0 Posts
Question Javascript Function containing <?xml in xslt file unexpected delceration

Good day, I need help.

Javascript Function containing <?xml in xslt file unexpected delceration
I need to add a javascript function in my xslt file but the function contains
<?xmlversion="1.0"encoding="utf-8"?>' and i get the error unexpected decleration.

In the xslt file it is already specified at the top of the xslt file - Please help

<?
xmlversion="1.0"?>
<
xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform"version="1.0"xmlns:asp="remove"xmlns:igchart="remove"xmlns:igsch="remove"xmlns:igtxt="remove">
<
xsl:outputomit-xml-declaration = "yes" />
<
xsl:templatematch="/">

<
SCRIPTTYPE='text/javascript'>
function SaveListItem()
{
var soapRequest = '
<?xmlversion="1.0"encoding="utf-8"?>' +
'
<soap12:Envelopexmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">' +
'
<soap12:Body>'+
'
<UpdateListItemsxmlns="http://schemas.microsoft.com/sharepoint/soap/">'+
'
<listName>{FE9526F8-1B17-40E5-9A91-56DCE868CF81}</listName>'+
'
<updates>'+
'
<BatchOnError="Continue">'+
'
<MethodID="1"Cmd="New">'+
'
<FieldName="ID">New</Field>'+
'
<FieldName="Title">TestData</Field>'+
'
</Method>'+
'
</Batch>'+
'
</updates>'+
'
</UpdateListItems>'+
'
</soap12:Body>'+
'
</soap12:Envelope>';
xmlHttp=new XMLHttpRequest();
xmlHttp.open('post', 'http://srv08-za143/workspace/departments/masterfiles/Vendor%20Takeon/_vti_bin/Lists.asmx', true);
xmlHttp.setRequestHeader('Content-Type','application/soap+xml; charset=utf-8');
xmlHttp.send(soapRequest);
}

</
SCRIPT>
 
Old January 6th, 2010, 07:26 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Consider to put the JavaScript code into a .js file and then include that with <script type="text/javascript" src="file.js"></script>.
If you want to put the script code in the XSLT stylesheet then you need to escape it according to XML rules e.g. '&lt;' for '<'.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old January 6th, 2010, 07:48 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 115
Thanks: 2
Thanked 0 Times in 0 Posts
Question

Thank You

How would i create a js file.

do i insert the code in notepad with file extension .js ?
 
Old January 6th, 2010, 07:52 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Use any text editor you like and save the JavaScript code with file extension '.js'.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog

Last edited by Martin Honnen; January 6th, 2010 at 07:54 AM.. Reason: correcting typo
 
Old January 6th, 2010, 08:28 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 115
Thanks: 2
Thanked 0 Times in 0 Posts
Default

My friend Thank You
I managed to get the js to execute.

Unfortunately my method to update a Sharepoint list using Web service
as not work.

I tried VBScript, Javascript - no luck


Thank You
 
Old January 6th, 2010, 08:41 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Putting the code in a separate file is best practice but you could also split the declaration up:
Code:
var soapRequest = '<' + '?' + 'xmlversion="1.0"encoding="utf-8"?>' +
As to your subsequent problem that's a different one altogether. You'll need to start a new thread, possibly in the SharePoint forum, and give details of what you're attempting and what's happening.
__________________
Joe
http://joe.fawcett.name/
 
Old January 6th, 2010, 08:51 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 115
Thanks: 2
Thanked 0 Times in 0 Posts
Default

it complains about
'
<' + '?'





Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript and XML...how to convert an Xslt file to DOM obj krraleigh BOOK: Professional JavaScript for Web Developers 2nd edition ISBN: 9780470227800 1 December 9th, 2009 09:55 PM
Regarding xml-html transformation of an xml string using xslt and javascript suprakash444 XSLT 1 January 12th, 2009 01:23 AM
Formating <li> as per xml using xslt 1.0 tims XSLT 9 May 12th, 2008 01:30 AM
javascript function in xslt swapnilp1983 XSLT 16 November 7th, 2006 12:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.