xml.bend checks
raw source on the hub · import bend-kit-sigv4@0.15.0.1/xml.bend as Xml
Pure XML parsing for S3 responses.
1 import
import Base
Types
type Leaf source · line 5 · raw
Data
One closed element: its parent's name, its name, and its own text, entities decoded. Names drop any namespace prefix.
Leaf@parent:String -> @name:String -> @text:String -> Leaf
type Lx source · line 11 · raw
Data
Where the lexer is: text; after '<'; a start tag's name; its attributes, outside or in "..." or '...'; after '/' in a start tag; an end tag's name; <?...?>, after '?'; after '<!'; a comment, after one or two '-'; <![CDATA[ up to its '['; CDATA, after one or two ']'; an entity; <!DOCTYPE ...>.
LTextLx
LOpenLx
LNameLx
LAttrLx
LDqLx
LSqLx
LSelfLx
LEndLx
LPiLx
LPiQLx
LBangLx
LComLx
LCom1Lx
LCom2Lx
LCdHeadLx
LCdLx
LCd1Lx
LCd2Lx
LEntLx
LDeclLx
type St source · line 35 · raw
Data
stack: open names, innermost first. txt and nm: text and the name or entity so far, reversed. out: leaves, last first. ok turns False at a mismatched end tag or an unknown entity.
St@stack:List<&2, String> -> @txt:String -> @nm:String -> @out:List<&2, Leaf> -> @ok:Bool -> St
type Page source · line 316 · raw
@-O:Data -> Data
Page@-O:Data -> @objects:List<&2, O> -> @prefixes:List<&2, String> -> @next:Maybe<&2, String> -> Page<O>
type Acc source · line 319 · raw
@-O:Data -> Data
Acc@-O:Data -> @key:String -> @size:Nat -> @etag:String -> @modified:String -> @objs:List<&2, O> -> @pre:List<&2, String> -> @cut:Bool -> @next:String -> Acc<O>
Definitions
def first source · line 38 · raw
@xs:List<&2, String> -> String
def local.go source · line 45 · raw
@s:String -> @acc:String -> String
def local source · line 55 · raw
@s:String -> String
The name after its namespace prefix, as Key for s3:Key.
def st.txt source · line 58 · raw
@st:St -> @c:Char -> St
def st.nm source · line 62 · raw
@st:St -> @c:Char -> St
def st.nm0 source · line 66 · raw
@st:St -> St
def st.open source · line 70 · raw
@st:St -> St
def st.shut source · line 74 · raw
@stack:List<&2, String> -> @txt:String -> @out:List<&2, Leaf> -> @ok:Bool -> @+name:String -> St
def st.close source · line 81 · raw
@st:St -> St
def st.close.top source · line 85 · raw
@st:St -> St
def hex.digit source · line 89 · raw
@+c:U32 -> Maybe<&2, U32>
def hex.step source · line 94 · raw
@m:Maybe<&2, U32> -> @+acc:U32 -> Maybe<&2, U32>
def hex source · line 102 · raw
@s:String -> @m:Maybe<&2, U32> -> Maybe<&2, U32>
ponytail: no overflow check; a reference past U+10FFFF wraps and decodes to junk rather than failing.
def ent.num source · line 113 · raw
@+s:String -> Maybe<&2, U32>
def ent source · line 117 · raw
@+e:String -> Maybe<&2, U32>
The five XML entities and &#NN; / &#xHH;. None for any other.
def st.ent.of source · line 125 · raw
@m:Maybe<&2, U32> -> @st:St -> St
def st.ent source · line 133 · raw
@st:St -> St
def lx.idle source · line 137 · raw
@m:Lx -> Bool
def st.end source · line 144 · raw
@m:Lx -> @st:St -> St
def lex source · line 149 · raw
@s:String -> @m:Lx -> @st:St -> St
One pass over the text. Each step takes one char, so it ends.
def xml.if source · line 274 · raw
@ok:Bool -> @out:List<&2, Leaf> -> Maybe<&2, List<&2, Leaf>>
def closed source · line 281 · raw
@xs:List<&2, String> -> Bool
def xml.fin source · line 288 · raw
@st:St -> Maybe<&2, List<&2, Leaf>>
def xml source · line 294 · raw
@s:String -> Maybe<&2, List<&2, Leaf>>
The closed elements of a document in document order, or None when it is not well formed. ponytail: no DTD internal subsets, and no check of names or attribute syntax; S3 sends neither.
def fault.scan source · line 300 · raw
@ls:List<&2, Leaf> -> @code:String -> @msg:String -> Pair(String, String)
S3's <Error><Code>..</Code><Message>..</Message></Error>.
def fault source · line 309 · raw
@m:Maybe<&2, List<&2, Leaf>> -> Pair(String, String)
def nat source · line 322 · raw
@s:String -> Nat
def page.root.last source · line 358 · raw
@ls:List<&2, Leaf> -> @+n:String -> String
Templates
template page.objects source · line 325 · raw
@-O:Data -> @-object:(@_:String -> @_:Nat -> @_:String -> @_:String -> O) -> @done:Bool -> @key:String -> @size:Nat -> @etag:String -> @modified:String -> @objs:List<&2, O> -> List<&2, O>
template page.leaf source · line 332 · raw
@-O:Data -> @-object:(@_:String -> @_:Nat -> @_:String -> @_:String -> O) -> @a:Acc<O> -> @+p:String -> @+n:String -> @+x:String -> Acc<O>
template page.scan source · line 346 · raw
@-O:Data -> @-object:(@_:String -> @_:Nat -> @_:String -> @_:String -> O) -> @ls:List<&2, Leaf> -> @a:Acc<O> -> Acc<O>
template page.fin source · line 353 · raw
@-O:Data -> @a:Acc<O> -> Page<O>
template page.if source · line 365 · raw
@-O:Data -> @-object:(@_:String -> @_:Nat -> @_:String -> @_:String -> O) -> @good:Bool -> @ls:List<&2, Leaf> -> Maybe<&2, Page<O>>
template page source · line 372 · raw
@-O:Data -> @-object:(@_:String -> @_:Nat -> @_:String -> @_:String -> O) -> @m:Maybe<&2, List<&2, Leaf>> -> Maybe<&2, Page<O>>