#lang racket (require (planet lizorkin/sxml:2:1/sxml)) (require (planet lizorkin/ssax:2:0/ssax)) (define definition (ssax:xml->sxml (open-input-file "../ebus-xml/ebus.xml") '[(#f . "http://xapek.org/ebus/0.1")])) (define (ebus-paket primaryCommand secondaryCommand) ((sxpath (string-append "//packet[@primary=" (number->string primaryCommand) " and @secondary=" (number->string secondaryCommand) "]")) definition)) ;; returns the full device-definition (define (device address) ((sxpath (string-append "//devices/device[@address=" (number->string address) "]")) definition)) ;; returns device-name in a list or empty-list (define (device-name address) ((sxpath "@name/text()") (device address))) (provide (prefix-out layer7- ebus-paket) (prefix-out layer7- device) (prefix-out layer7- device-name))