OutputParameters.py :  » XML » 4Suite » 4Suite-XML-1.0.2 » Ft » Xml » Xslt » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » XML » 4Suite 
4Suite » 4Suite XML 1.0.2 » Ft » Xml » Xslt » OutputParameters.py
########################################################################
# $Header: /var/local/cvsroot/4Suite/Ft/Xml/Xslt/OutputParameters.py,v 1.7 2005/10/19 15:02:59 uogbuji Exp $
"""
Represents XSLT output parameters governed by the xsl:output instruction
See also Ft.Xml.Xslt.OutputHandler

Copyright 2003 Fourthought, Inc. (USA).
Detailed license and copyright information: http://4suite.org/COPYRIGHT
Project home, documentation, distributions: http://4suite.org/
"""

from Ft.Xml.Xslt.AttributeValueTemplate import AttributeValueTemplate
from Ft.Xml.XPath import FT_EXT_NAMESPACE

class OutputParameters:
    
    def __init__(self):
        self.method = None
        self.version = None
        self.encoding = None
        self.omitXmlDeclaration = None
        self.standalone = None
        self.doctypeSystem = None
        self.doctypePublic = None
        self.mediaType = None
        self.cdataSectionElements = []
        self.indent = None
        self.utfbom = None

    def clone(self):
        clone = OutputParameters()
        clone.__dict__.update(self.__dict__)
        return clone

    def setDefault(self, attr, value):
        if not self.__dict__.has_key(attr):
            raise AttributeError(attr)

        if self.__dict__[attr] is None:
            self.__dict__[attr] = value
        return

    def avtParse(self, owner, context):
        """
        evaluates the given node for valid xsl:output-like attributes
        expressed in AVTs of extension elements, storing the values
        in instance variables.  If called repeatedly, it will overwrite
        old values.
        """
        method = owner._method.evaluate(context)
        if method is not None:
            self.method = method

        version = owner._version.evaluate(context)
        if version is not None:
            self.version = version

        encoding = owner._encoding.evaluate(context)
        if encoding is not None:
            self.encoding = encoding

        omit_xml_decl = owner._omit_xml_declaration.evaluate(context)
        if omit_xml_decl is not None:
            self.omitXmlDeclaration = omit_xml_decl

        standalone = owner._standalone.evaluate(context)
        if standalone is not None:
            self.standalone = standalone and 'yes' or 'no'

        doctype_system = owner._doctype_system.evaluate(context)
        if doctype_system is not None:
            self.doctypeSystem = doctype_system

        doctype_public = owner._doctype_public.evaluate(context)
        if doctype_public is not None:
            self.doctypePublic = doctype_public

        media_type = owner._media_type.evaluate(context)
        if media_type is not None:
            self.mediaType = media_type

        # cdata-section-elements are merged while the others are replaced
        self.cdataSectionElements.extend(
            owner._cdata_section_elements.evaluate(context)
            )

        indent = owner._indent.evaluate(context)
        if indent is not None:
            self.indent = indent

        if owner.attributes.has_key((FT_EXT_NAMESPACE, 'utf-bom')):
            utfbom = owner.attributes[(FT_EXT_NAMESPACE, 'utf-bom')].evaluate(context)
            if utfbom is not None:
                self.utfbom = utfbom
        return

    def parse(self, owner):
        """
        parses the given node (owner) for valid xsl:output attributes
        and stores their values in instance variables.
        If called repeatedly, it will overwrite old values (this ensures
        behavior mandated by the spec, in which the last xsl:output element
        is established with highest precedence).
        """
        if owner._method is not None:
            self.method = owner._method

        if owner._version is not None:
            self.version = owner._version

        if owner._encoding is not None:
            self.encoding = owner._encoding

        if owner._omit_xml_declaration is not None:
            self.omitXmlDeclaration = owner._omit_xml_declaration

        if owner._standalone is not None:
            self.standalone = owner._standalone and 'yes' or 'no'

        if owner._doctype_system is not None:
            self.doctypeSystem = owner._doctype_system

        if owner._doctype_public is not None:
            self.doctypePublic = owner._doctype_public

        if owner._media_type is not None:
            self.mediaType = owner._media_type

        # cdata-section-elements are merged while the others are replaced
        self.cdataSectionElements.extend(owner._cdata_section_elements)

        if owner._indent is not None:
            self.indent = owner._indent

        if owner.attributes.has_key((FT_EXT_NAMESPACE, 'utf-bom')):
            self.utfbom = owner.attributes[(FT_EXT_NAMESPACE, 'utf-bom')]
        return

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.