Skip to content

Determining whether an element is solely a text element or not within the Ginja template? #409

Closed Answered by brunato
ethindp asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

about the 1st question: you have to look at the type. Each type has a content type, that can be:

  1. empty
  2. simple
  3. mixed
  4. element-only

for checking if the content of the element is only a text use:

xsd_element.type.has_simple_content()

if you don't mind about empty cases add also is_empty().

For checking if the element has declared attributes use len(xsd_element.attributes) == 0 (or not xsd_element.attributes).

For the second question, if you define a subclass for C++ starting with:

class CPPGenerator(AbstractGenerator):
    """A C++ code generator for XSD schemas."""

    formal_language = 'CPP'

    ...

the auto-generated filter will be cpp_type.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ethindp
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants