views:

142

answers:

5
+1  Q: 

Compile to xslt?

The answer to this may very well be no, as much searching has turned up nothing. I thought long ago I saw something like this, but it may all have been a mirage.

Basically, it's so atrociously awful writing xslt out by hand. It's not the functional paradigm that bothers me. What bothers me is the fact that it uses XML based syntax. I wonder if there's anything available that can compile from some simpler more legible syntax into an XSLT stylesheet. Doesn't have to have curly brackets, but the angle brackets are a bit eye boggling.

thanks.

A: 

I don't know of any compiler yet to convert to XSLT.

However I do know a few tools/ide's that can make working in XSLT easier.

Stylus Studio

Netbeans IDE this is free

You could also find an open source tool here.

Kevin Boyd
+1  A: 

I suppose you could write JSON and convert it to XML. JSON.NET is capable of converting between the two formats.

This XML:

<!DOCTYPE glossary PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
 <glossary><title>example glossary</title>
  <GlossDiv><title>S</title>
   <GlossList>
    <GlossEntry ID="SGML" SortAs="SGML">
     <GlossTerm>Standard Generalized Markup Language</GlossTerm>
     <Acronym>SGML</Acronym>
     <Abbrev>ISO 8879:1986</Abbrev>
     <GlossDef>
      <para>A meta-markup language, used to create markup
languages such as DocBook.</para>
      <GlossSeeAlso OtherTerm="GML">
      <GlossSeeAlso OtherTerm="XML">
     </GlossDef>
     <GlossSee OtherTerm="markup">
    </GlossEntry>
   </GlossList>
  </GlossDiv>
 </glossary>

Looks like this in JSON:

{
    "glossary": {
        "title": "example glossary",
        "GlossDiv": {
            "title": "S",
        "GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
   "SortAs": "SGML",
   "GlossTerm": "Standard Generalized Markup Language",
   "Acronym": "SGML",
   "Abbrev": "ISO 8879:1986",
   "GlossDef": {
                                 "para": "A meta-markup language, used to create markup languages such as DocBook.",
            "GlossSeeAlso": ["GML", "XML"]
                           },
         "GlossSee": "markup"
                }
            }
        }
    }
}
Robert Harvey
+2  A: 

You could translate S-expressions as SXML to XML. Instead of using angle brackets, this would use parentheses with a slightly less cluttered syntax:

(xsl:template (@ (name "mytemplate"))
  (xsl:if (@ (test "foo = 'bar'"))
    (xsl:value-of (@ (select "@baz")))))

Whether this is an improvement over XML depends on your personal tastes, of course.

Greg Hewgill
A: 

If you want something that has (most of) the expressive power of XSLT when dealing with XML document, but you dislike the verbose syntax outside of XPath, then maybe you should have a look at XQuery.

Pavel Minaev
I've not seen any browser that natively supports Xquery, and yet all the major browsers support XSLT.
Breton
Browsers are a fairly minor niche for XSLT - it has many more uses than that, and I would even argue that it's pretty pointless in a browser. Besides, XQuery is an alternative to XSLT 2.0, not 1.0 - and all browsers I know only support 1.0.
Pavel Minaev
A: 

The Oxygen XML application works wonders when it comes to maintaining anything SGML based. Don't try to write your XSLT in notepad, you'll probably end up suicidal :)

http://www.oxygenxml.com/

Richard Seviora