On this page:
ssax:  xml->sxml
sxml:  document

2 SAX Parsing

procedure

(ssax:xml->sxml port    
  namespace-prefix-assig)  sxml?
  port : input-port?
  namespace-prefix-assig : (listof (cons/c symbol? string?))
Reads an XML document (which can be a single XML element) from port, and returns the corresponding SXML (top) representation. The namespace-prefix-assig association list provides shortened forms to be used in place of namespaces.

Examples:
> (ssax:xml->sxml
   (open-input-string
    "<zippy><pippy pigtails=\"2\">ab</pippy>cd</zippy>")
   '())

'(*TOP* (zippy (pippy (@ (pigtails "2")) "ab") "cd"))

> (ssax:xml->sxml
    (open-input-string
     "<car xmlns=\"vehicles\"><wheels>4</wheels></car>")
    '())

'(*TOP* (vehicles:car (vehicles:wheels "4")))

> (ssax:xml->sxml
    (open-input-string
     "<car xmlns=\"vehicles\"><wheels>4</wheels></car>")
    '((v . "vehicles")))

'(*TOP* (@ (*NAMESPACES* (v "vehicles"))) (v:car (v:wheels "4")))

procedure

(sxml:document url-string    
  namespace-prefix-assig)  sxml?
  url-string : string?
  namespace-prefix-assig : any/c
Given a local file URI, return the corresponding SXML representation.

NOTE: currently, this appears to work only for local documents.

NAMESPACE-PREFIX-ASSIG - is passed as-is to the SSAX parser: there it is used for assigning certain user prefixes to certain namespaces.

NAMESPACE-PREFIX-ASSIG is an optional argument and has an effect for an XML resource only. For an HTML resource requested, NAMESPACE-PREFIX-ASSIG is silently ignored.

So, for instance, if the file "/tmp/foo.xml" contains an XML file, you should be able to call

(sxml:document "file:///tmp/foo")

(Note the plethora of slashes required by the URI format.)