[x3d-public] Trying to use X3dToJson.xslt in web page to produce JSON.

John Carlson yottzumm at gmail.com
Sat Nov 28 02:00:00 PST 2015


It doesn’t work because it’s an XSLT 2.0 stylesheet.  You can use it with SaxonCE, available here: http://saxonica.com/ce/index.xml <http://saxonica.com/ce/index.xml>

John

> On Nov 28, 2015, at 3:30 AM, John Carlson <yottzumm at gmail.com> wrote:
> 
> Okay, I was able to replace X3dToJson.xslt with xml2json.xsl and my webpage “worked.”  So now we have to track down why Don’s stylesheet doesn’t work in browsers.  My brain is coming back to life.
> 
> John
>> On Nov 28, 2015, at 2:31 AM, John Carlson <yottzumm at gmail.com <mailto:yottzumm at gmail.com>> wrote:
>> 
>> I tried removing all line breaks outputted from the stylesheet.  Same result.  and xmlsh works.  This is getting strange.
>> 
>> John
>>> On Nov 28, 2015, at 1:35 AM, John Carlson <yottzumm at gmail.com <mailto:yottzumm at gmail.com>> wrote:
>>> 
>>> Don, I’m trying to use X3dToJson.xslt in a web page to produce JSON from X3D XML.
>>> 
>>> Here’s what I get:
>>> 
>>> 
>>> { "X3D": {
>>> 
>>> 
>>> Here’s my function:
>>> 
>>> 	function convertXMLToJSON() {
>>> 		$.get("X3dToJson.xslt", function(xsl) {
>>> 			var content = $('textarea#xml').val();
>>> 			var xml = $.parseXML(content);
>>> 			// code for IE
>>> 			if (window.ActiveXObject) {
>>> 				json = xml.transformNode(xsl);
>>> 			}
>>> 			// code for Chrome, Firefox, Opera, etc.
>>> 			else if (document.implementation && document.implementation.createDocument) {
>>> 				xsltProcessor = new XSLTProcessor();
>>> 				xsltProcessor.importStylesheet(xsl);
>>> 				json = xsltProcessor.transformToDocument(xml);
>>> 			}
>>> 			console.log('JSON', json);
>>> 			$('textarea#json').val(getXmlString(json));
>>> 		}, "xml");
>>> 	}
>>> 
>>> The stylesheet and input works fine in xmlsh.  Would it be possible to change a stylesheet parameter to not emit newlines or line breaks—or possibly remove all line breaks in output at the end—or my problem might be solved a different way?  I’m going to work on a simpler example.
>>> 
>>> John
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20151128/e54f74d4/attachment.html>


More information about the x3d-public mailing list