Class XmlDirectConstructorTranslation

java.lang.Object
org.rumbledb.compiler.translation.xml.XmlDirectConstructorTranslation

public final class XmlDirectConstructorTranslation extends Object
Translation logic for XML direct constructors (elements, comments, processing instructions, attributes, and content). Operates on parser-agnostic context adapters so that direct constructor AST construction is shared between JSONiq and XQuery.
  • Method Details

    • directConstructor

      public static <QnameCtx extends org.antlr.v4.runtime.ParserRuleContext, DirElemContentCtx extends org.antlr.v4.runtime.ParserRuleContext, ExprCtx extends org.antlr.v4.runtime.ParserRuleContext> Expression directConstructor(DirectConstructorContext<QnameCtx,ExprCtx,DirElemContentCtx> ctx, org.antlr.v4.runtime.CommonTokenStream tokenStream, TranslationContext translationContext, BiFunction<QnameCtx,TranslationNameResolver.NameRole,Name> parseName, Function<DirElemContentCtx,Expression> visitDirElemContent, Function<ExprCtx,Expression> visitExpr)
      Translates a direct constructor (element, comment, or processing instruction) into an Expression.
      Type Parameters:
      QnameCtx - the parse-tree context type for QNames
      DirElemContentCtx - the parse-tree context type for direct element content
      ExprCtx - the parse-tree context type for expressions
      Parameters:
      ctx - the direct constructor context adapter
      tokenStream - the common token stream
      translationContext - the current translation context
      parseName - function resolving a QName to a Name
      visitDirElemContent - visitor function for direct element content
      visitExpr - visitor function for general expressions
      Returns:
      the translated direct constructor expression
    • dirElemContent

      public static <DirectConstructorCtx extends org.antlr.v4.runtime.ParserRuleContext, CommonContentCtx extends org.antlr.v4.runtime.ParserRuleContext> Expression dirElemContent(DirElemContentContext<DirectConstructorCtx,CommonContentCtx> ctx, org.antlr.v4.runtime.CommonTokenStream tokenStream, TranslationContext translationContext, Function<DirectConstructorCtx,Expression> visitDirectConstructor, Function<CommonContentCtx,Expression> visitCommonContent)
      Translates direct element content (nested direct constructor, common content, CDATA, or literal text) into an Expression.
      Type Parameters:
      DirectConstructorCtx - the parse-tree context type for direct constructors
      CommonContentCtx - the parse-tree context type for common content
      Parameters:
      ctx - the element content context adapter
      tokenStream - the common token stream
      translationContext - the current translation context
      visitDirectConstructor - visitor function for nested direct constructors
      visitCommonContent - visitor function for common content
      Returns:
      the translated element content expression
    • commonContent

      public static <ExprCtx extends org.antlr.v4.runtime.ParserRuleContext> Expression commonContent(CommonContentContext<ExprCtx> ctx, TranslationContext translationContext, Function<ExprCtx,Expression> visitExpr)
      Translates direct constructor common content (enclosed expression or literal content) into an Expression.
      Type Parameters:
      ExprCtx - the parse-tree context type for expressions
      Parameters:
      ctx - the common content context adapter
      translationContext - the current translation context
      visitExpr - visitor function for expressions
      Returns:
      the translated common content expression