Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Example  





2 References  





3 External links  














SXML









 

Edit links
 









Article
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Cite this page
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 


SXML
Filename extension
.sxml, .scm
Type codeTEXT
Type of formatmarkup language

SXML is an alternative syntax for writing XML data (more precisely, XML Infosets[1]) as S-expressions, to facilitate working with XML data in Lisp and Scheme. An associated suite of tools[which?] implements XPath, SAX and XSLT for SXML in Scheme[2][3] and are available in the GNU Guile implementation of that language.

Textual correspondence between SXML and XML for a sample XML snippet is shown below:

XML SXML
<tag attr1="value1"
     attr2="value2">
  <nested>Text node</nested>
  <empty/>
</tag>
(tag (@ (attr1 "value1")
        (attr2 "value2"))
  (nested "Text node")
  (empty))

Compared to other alternative representations for XML and its associated languages, SXML has the benefit of being directly parsable by existing Scheme implementations. The associated tools and documentation were praised in many respects by David Mertz in his IBM developerWorks column, though he also criticized the preliminary nature of its documentation and system.[4]

Example

[edit]

Take the following simple XHTML page:

 <html xmlns="http://www.w3.org/1999/xhtml"
         xml:lang="en" lang="en">
    <head>
       <title>An example page</title>
    </head>
    <body>
       <h1 id="greeting">Hi, there!</h1>
       <p>This is just an "&gt;&gt;example&lt;&lt;" to show XHTML &amp; SXML.</p>
    </body>
 </html>

After translating it to SXML, the same page now looks like this:

 (*TOP* (@ (*NAMESPACES* (x "http://www.w3.org/1999/xhtml")))
  (x:html (@ (xml:lang "en") (lang "en"))
    (x:head
       (x:title "An example page"))
    (x:body
       (x:h1 (@ (id "greeting")) "Hi, there")
       (x:p  "This is just an \">>example<<\" to show XHTML & SXML."))))

Each element's tag pair is replaced by a set of parentheses. The tag's name is not repeated at the end, it is simply the first symbol in the list. The element's contents follow, which are either elements themselves or strings. There is no special syntax required for XML attributes. In SXML they are simply represented as just another node, which has the special name of @. This can't cause a name clash with an actual "@" tag, because @ is not allowed as a tag name in XML. This is a common pattern in SXML: anytime a tag is used to indicate a special status or something that is not possible in XML, a name is used that does not constitute a valid XML identifier.

In SXML strings there are two characters that must be escaped, the " string delimiter (with \") and the \ escape symbol itself (with \\). The XML code above requires escaping three: & , < and > (with &amp; ,&lt;and &gt; respectively).

References

[edit]
  1. ^ Kiselyov, Oleg (2002). "SXML Specification". ACM SIGPLAN Notices. 37 (6): 52–58. doi:10.1145/571727.571736. S2CID 13955814.
  • ^ Kiselyov, Oleg; Lisovsky, Kirill (2002). XML, XPath, XSLT Implementations as SXML, SXPath, and SXSLT (PDF). International Lisp Conference.
  • ^ Kiselyov, Oleg; Krishnamurthi, Shriram (2003). SXSLT: Manipulation Language for XML. Practical Aspects of Declarative Languages. Lecture Notes in Computer Science. Vol. 2562. pp. 256–272. doi:10.1007/3-540-36388-2_18. ISBN 978-3-540-00389-2.
  • ^ Mertz, David (23 October 2003). "XML Matters: Investigating SXML and SSAX". IBM developerWorks. Archived from the original on 4 December 2004. Retrieved 10 January 2015.
  • [edit]
    Retrieved from "https://en.wikipedia.org/w/index.php?title=SXML&oldid=1211757400"

    Categories: 
    Markup languages
    Technical communication
    Scheme (programming language)
    Hidden categories: 
    All articles with specifically marked weasel-worded phrases
    Articles with specifically marked weasel-worded phrases from June 2016
     



    This page was last edited on 4 March 2024, at 07:54 (UTC).

    Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Mobile view



    Wikimedia Foundation
    Powered by MediaWiki