Class XsltInstance

java.lang.Object
eu.bandm.tools.d2d2.base.XsltInstance

public class XsltInstance extends Object
Instantiates the generic d2d xslt module definition for some particular target doctype. Create one instance for each target format and invoke prepareXsltMode().
  • Field Details

    • xslt_modulename

      public static final String xslt_modulename
      Name of the generic d2d xslt module definition.
      See Also:
    • xslt_generic_tag_for_backend_elements

      public static final String xslt_generic_tag_for_backend_elements
      Tag which appears in the d2d xslt module definition as placeholder for target format elements.
      See Also:
    • xslt_tag_toplevel

      public static final String xslt_tag_toplevel
      The tag used for the top-level element of an xslt program. The standard allows two variants, we support only one of these.
      See Also:
    • xslt_tag_ubiquituous

      public static final String xslt_tag_ubiquituous
      Name of an element definition in the d2d xslt module which or-s all xslt elements which can appear anywhere in a result elements contents.
      See Also:
    • toplevelXRegExp

      @Opt final @Opt XRegExp toplevelXRegExp
      The definition from which all possible (elements and attributes are reachable.
  • Constructor Details

  • Method Details

    • makealt

      public static Alt makealt(Collection<Reference> subs)
      Wraps the argument in an "alt" expression.
    • get_xslt_alt_ubiquituous

      Expression get_xslt_alt_ubiquituous()
      The alternative of all xslt expressions which can appear anyhere in a target format element.
    • get_xslt_alt_ubiquituous_repeated

      Expression get_xslt_alt_ubiquituous_repeated()
      A "star" repetition wrapped around xslt_alt_ubiquituous.
    • hint

      protected void hint(String text, Object... args)
      Emits a hint message iff tracelevel >0.
    • warning

      protected void warning(String text, Object... args)
      Emits a warning message iff tracelevel >0.
    • prepareXsltMode

      protected Module prepareXsltMode()
      The insertion of the target language classes into the content-containing xslt elements is done by once modifying the (copy of the) xslt definition module.

      Each reference to xslt_generic_tag_for_backend_elements == "RESULT_ELEMENTS" is hard rewritten to "(#chars|A|B|C)*", with "A", "B", etc. being all reachable target model element tags. (The XSLT specification implies that only Element tags, not Attribute tags, can appear in this "free floating" way.)

      All xslt-tags which appear in the xslt syntax (d2d-form!) as an alterative to RESULT_ELEMENTS thus compete/conflict with these target tags. The only place is the rule tags TEMPLATE = (#chars | @INSTRUCTIONS | @RESULT_ELEMENTS)*
      Thus all xslt tags in @CHAR_PRODUCING | @STRUCTURE_PRODUCING | @INTERSPERED_NOTHING_PRODUCING can conflict.
      These are: apply | call | apply-imports | foreach | valueof | copy-of | number | choose | if | text | copy | pi | comment | element | attribute | var | message | fallback.

      The other direction of inclusion, i.e. the callability of ubiquituous content-producing xslt elements out of target element's content is done dynamically, by special look-up code. See the local "boolean inxslt" in the code of Text2Udom.process_open_tag(String, boolean). These tags are collected in the disjunction expression "INSTRUCTIONS", and thus are (accidentally) the same as in the other direction.

      Only those tags will be replaced by prefixed versions on case of conflicts with target tags.

      The remaining few other xslt-tags (stylesheet, result_elements, version, extension, import, include,output, key, decimal-format, namspace, priority, match, noescap, value, count, from, format, arg, sort, test, when, other, attribute-set, param, xp) will not be replaced.

    • prepareXsltMode_text

      protected Module prepareXsltMode_text()
      For text mode the xslt module can be used directly, no rewriting is necessary but eliminating "xslt:RESULT_ELEMENTS"
    • errorcheck_xsltprepare

      protected void errorcheck_xsltprepare(MessageCounter cnt)
      Ensures that no errors (= no LL-1-violation-errors) have happend when resolving the combined definitions of xslt and target. These cannot happen because the xslt tags which conflict have been replaced by non-conflicting prefixed versions.