Search

@phoque: I’m happy with where my version of this is at now—it’s working as it should in my current project. Do you want to roll the alterations into your utility or shall I add it separately?

I think I will add them to mine if you don’t mind.

Of course not, add away! Much simpler that way.

I only have one concearn: I want to be able to address elements with attributes the same way as ones without attributes.

For now, the ones with attributes have a field “value”, the other ones don’t, right?

That’s right, yeah. Not sure there’s a particularly neat way around that.

I stumbled across this XSLTJSON utility today, it gets around the problem of what to do with attributes by appending @ to the start of those objects. Thought it might be of interest to those who want some dead simple JSON action.

@makenosound

Nice! thanks. Just for posterity, be sure to get the ‘lite’ version from the Makenosound’s link if you want to use it in Symphony (XSLT 1 version).

where’s this file:

<xsl:import href=”../../utilities/generic/string-replace.xsl” />

i don’t see it in the default 2.0.8 rc3 build

It’s a XSLT utility from the downloads section.

ah, thanks klaftertief

I stumbled across this XSLTJSON utility today,

I can’t open that page. Can anyone post it here?

Here is a cached version and i found this utility helpful as well.

Cheers Jonas!

i was having some issues with arrays being created (ie. multiple <entry> modes) so i modified @makenosound’s latest gist (didn’t fork it) - xml2json. not too much was really changed, just added some variables and to use in place of some xpath. The biggest change was selecting just [1]st previous or next sibling in the xml. haven’t done any extensive testing, though.

does anyone know how to strip the line breaks from a node with formatted html output? i already have <xsl:strip-space elements="* | @*" /> in the template, but that doesn’t seem to do anything to nodes with html in it (using tinymce editor):

<bio mode="formatted">&lt;p&gt;This is plain only now.  &lt;strong&gt;This is bold.
&lt;em&gt;This is bold and italic.  &lt;span style=&quot;text-decoration: 
underline;&quot;&gt;This is bold, italic, and underlined.&lt;/span&gt;&lt;span
style=&quot;font-style: normal; font-weight: normal;&quot;&gt; This text is back to
normal.&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I have one unordered list item&lt;/li&gt;
&lt;li&gt;A second item&lt;/li&gt;
&lt;li&gt;And finally a third item&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;ol&gt;
&lt;li&gt;This is an ordered list: 1&lt;/li&gt;
&lt;li&gt;this is an ordered list: 2&lt;/li&gt;
&lt;li&gt;And this is 3&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;Need to remove all these line breaks on the output&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;</bio>

i added the 'json' => 'application/json' mapping to the config.php file, but i’m still seeing this as my content type header:

Content-Type    text/html; charset=utf-8

I added json as the Page Type, but that didn’t seem to do anything for me. What am i missing still?

I’m sure that should be 'json' => 'application/x-javascript', I’ve never heard of the application/json mime type, and it is JavaScript after all…

I guess you’ve got the Content Type Mappings extension enabled then?

ya i have the Content Type Mappings extensions installed. I’m looking to only return json snippets and have been seeing application/json as the mime type for that. A quick google search points me to a stack overflow post to confirm this.

Well you learn something new every day! Thanks for pointing that out.

Hello

I have problem with receive json from my page. Could someone show a jquery script? My script does not cause errors and no gives the results.

In the console, the request is displayed twice, once with a 200 OK status and type of application / json, a second time with a status 301 Moved Permanently and type text / html.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details