2.2 Generating XML Strings
(require scribble/html/xml) | package: scribble-html-lib |
procedure
(output-xml content [port]) → void?
content : outputable/c port : output-port? = (current-output-port)
procedure
(xml->string content) → string?
content : outputable/c
parameter
(xml-writer) → ((string? output-port? . -> . void))
(xml-writer writer) → void? writer : ((string? output-port? . -> . void))
procedure
(make-element tag attrs content)
→ (and/c procedure outputable/c?) tag : symbol? attrs : (listof (cons/c symbol? outputable/c)) content : outputable/c
When an attribute in attrs is mapped to #f, then it is skipped. When an attribute is mapped to #t, then it is rendered as present, but without a value.
> (output-xml (make-element 'b '() '("Try" #\space "Racket"))) <b>Try Racket</b>
> (output-xml (make-element 'a '((href . "http://racket-lang.org")) "Racket")) <a href="http://racket-lang.org">Racket</a>
> (output-xml (make-element 'div '((class . "big") (overlay . #t)) "example")) <div class="big" overlay>example</div>
procedure
(element tag attrs-and-content ...)
→ (and procedure outputable/c?) tag : symbol? attrs-and-content : any/c
> (output-xml (element 'b "Try" #\space "Racket")) <b>Try Racket</b>
> (output-xml (element 'a 'href: "http://racket-lang.org" "Racket")) <a href="http://racket-lang.org">Racket</a>
> (output-xml (element 'div 'class: "big" 'overlay: #t "example")) <div class="big" overlay>example</div>
> (require scribble/html)
> (output-xml (element 'div class: "big" overlay: #t "example")) <div class="big" overlay>example</div>
procedure
(element/not-empty tag attrs-and-content ...) → (and/c procedure? outputable/c) tag : symbol? attrs-and-content : any/c
> (output-xml (element 'span)) <span />
> (output-xml (element/not-empty 'span)) <span></span>
procedure
(attribute? v) → (or/c #f symbol?)
v : any/c
> (attribute? 'a:) 'a
> (attribute? 'a) #f
> (require scribble/html)
> (attribute? a:) 'a
procedure
(split-attributes+body lst) →
list? list? lst : list?
procedure
(literal content ...) → procedure?
content : any/c
> (output-xml (literal "a->b")) a->b
> (output-xml "a->b") a->b
procedure
(entity v) → procedure?
v : (or/c exact-integer? symbol?)
> (output-xml (entity 'gt)) >
procedure
(comment content ... [#:newlines? newlines?]) → procedure?
content : outputable/c newlines? : any/c = #f
> (output-xml (comment "testing" 1 2 3)) <!--testing123-->
procedure
(cdata content ... [ #:newlines? newlines? #:line-pfx line-pfx]) → procedure? content : outputable/c newlines? : any/c = #t line-pfx : any/c = #f
> (output-xml (cdata "testing" 1 2 3))
<![CDATA[
testing123
]]>
syntax
(define/provide-elements/empty tag-id ...)
syntax
(define/provide-elements/not-empty tag-id ...)
syntax
(define/provide-entities entity-id ...)