Skip to content

Eliminate wasteful namespace declarations (optimise the XML output) #555

@spaetow

Description

@spaetow

I'm currently working some code and have noticed that for the sake of a smaller XML file, if you have a lot of declarations like this, the namespace duplication is very wasteful:

        <saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
            xsi:type="xs:string">demouser</saml2:AttributeValue>

Wouldn't it then make sense to include the namespace once at the root? This is related to #249 and #336 (the lack of declaration of namespaces for xs: types).

Is there a way to optimise this somehow? See the XML assertion in
pysaml2-built-assertion-with-individual-namespace-declarations.txt, it is 2346 bytes long.

An optimised version (see
pysaml2-built-assertion-with-root-namespace-declaration.txt ) is only 2038 bytes long.

While in the grand scheme of things this 308-byte difference doesn't look like much, it does mean a lot in the case we have, where every byte counts towards a 4096 octet limit. @rohe knows which case I refer to (Moonshot).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions