================================================================================
api/xmlRendererHtml.xml
================================================================================

// a glimpse into rendering markup with XmlRenderer
import "pkl:xml"

function h1() = xml.Element("h1")
function ul() = xml.Element("ul")
function li() = xml.Element("li")
function strong() = (xml.Element("strong")) { isBlockFormat = false }
function comment(text: String) = xml.Comment(text)

hobbies {
  "swimming"
  "surfing"
  "fire making"
}

html {
  body {
    comment("this is a comment")
    (h1()) {
      "My " hobbies.toList().length " " (strong()) { "favorite" } " hobbies:"
    }
    (ul()) {
      for (hobby in hobbies) {
        (li()) { hobby }
      }
    }
  }
}

output {
  value = html
  renderer = new xml.Renderer {
    rootElementName = "html"
  }
}

--------------------------------------------------------------------------------

(module
  (lineComment)
  (importClause
    (stringConstant))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList))
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (slStringLiteral))))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList))
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (slStringLiteral))))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList))
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (slStringLiteral))))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList))
    (objectLiteral
      (parenthesizedExpr
        (methodCallExpr
          (variableExpr
            (identifier))
          (identifier)
          (argumentList
            (slStringLiteral))))
      (objectBody
        (objectProperty
          (identifier)
          (falseLiteral)))))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier)
          (typeAnnotation
            (type
              (qualifiedIdentifier
                (identifier)))))))
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (variableExpr
          (identifier)))))
  (classProperty
    (identifier)
    (objectBody
      (objectElement
        (slStringLiteral))
      (objectElement
        (slStringLiteral))
      (objectElement
        (slStringLiteral))))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (identifier)
        (objectBody
          (objectElement
            (methodCallExpr
              (identifier)
              (argumentList
                (slStringLiteral))))
          (objectElement
            (objectLiteral
              (parenthesizedExpr
                (methodCallExpr
                  (identifier)
                  (argumentList)))
              (objectBody
                (objectElement
                  (slStringLiteral))
                (objectElement
                  (propertyCallExpr
                    (methodCallExpr
                      (variableExpr
                        (identifier))
                      (identifier)
                      (argumentList))
                    (identifier)))
                (objectElement
                  (slStringLiteral))
                (objectElement
                  (objectLiteral
                    (parenthesizedExpr
                      (methodCallExpr
                        (identifier)
                        (argumentList)))
                    (objectBody
                      (objectElement
                        (slStringLiteral)))))
                (objectElement
                  (slStringLiteral)))))
          (objectElement
            (objectLiteral
              (parenthesizedExpr
                (methodCallExpr
                  (identifier)
                  (argumentList)))
              (objectBody
                (forGenerator
                  (typedIdentifier
                    (identifier))
                  (variableExpr
                    (identifier))
                  (objectBody
                    (objectElement
                      (objectLiteral
                        (parenthesizedExpr
                          (methodCallExpr
                            (identifier)
                            (argumentList)))
                        (objectBody
                          (objectElement
                            (variableExpr
                              (identifier)))))))))))))))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (identifier)
        (variableExpr
          (identifier)))
      (objectProperty
        (identifier)
        (newExpr
          (type
            (qualifiedIdentifier
              (identifier)
              (identifier)))
          (objectBody
            (objectProperty
              (identifier)
              (slStringLiteral))))))))
