# -*- coding: utf-8 -*-# cython: language_level=3, always_allow_keywords=True## Copyright 1999-2024 by LivingLogic AG, Bayreuth/Germany## Copyright 1999-2024 by Walter Dörwald#### All Rights Reserved#### See ll/xist/__init__.py for the license"""Contains the global attributes for the XML namespace (like ``xml:lang``),and classes for the XML declaration."""fromllimportxml_codecfromll.xistimportxsc,sims__docformat__="reStructuredText"xmlns=xsc.xml_xmlnsclassAttrs(xsc.Attrs):xmlns=xmlnsclassspace(xsc.TextAttr):xmlns=xmlnsvalues=("default","preserve")classlang(xsc.TextAttr):xmlns=xmlnsclassbase(xsc.URLAttr):xmlns=xmlns
[docs]classXML(xsc.ProcInst):""" XML declaration. The encoding will be automatically set when publishing. """xmlname="xml"def__init__(self,version="1.0",encoding="utf-8",standalone=None):v=[]v.append(f'version="{version}"')# According to http://www.w3.org/TR/2000/REC-xml-20001006#NT-XMLDecl version is requiredifencodingisnotNone:v.append(f'encoding="{encoding}"')ifstandaloneisnotNone:standalone="yes"ifstandaloneelse"no"v.append(f'standalone="{standalone}"')xsc.ProcInst.__init__(self," ".join(v))defpublish(self,publisher):xml=f"<?xml {self.content}?>"ifpublisher.encodingisnotNone:xml=xml_codec._fixencoding(xml,str(publisher.encoding))yieldpublisher.encode(xml)
[docs]classXMLStyleSheet(xsc.ProcInst):""" XML stylesheet declaration. """xmlname="xml-stylesheet"
[docs]classdeclaration(xsc.Element):""" The XML declaration as an element. This makes it possible to generate a declaration from within an XML file. """xmlns=xmlnsmodel=sims.Empty()defconvert(self,converter):node=XML()returnnode.convert(converter)