================================================================================
api/xmlRendererElement.xml
================================================================================

import "pkl:xml"

diskSizes = new Listing { 1200.gb; 2.tb }

output {
  renderer = new xml.Renderer {
    rootElementName = "machine"
    converters {
      ["diskSizes"] = (dss) -> dss.toList().map((ds) -> (xml.Element("disk")) { (xml.Element(ds.unit)) { ds.value } })
    }
  }
}

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

(module
  (importClause
    (stringConstant))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectElement
          (propertyCallExpr
            (intLiteral)
            (identifier)))
        (objectElement
          (propertyCallExpr
            (intLiteral)
            (identifier))))))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (identifier)
        (newExpr
          (type
            (qualifiedIdentifier
              (identifier)
              (identifier)))
          (objectBody
            (objectProperty
              (identifier)
              (slStringLiteral))
            (objectProperty
              (identifier)
              (objectBody
                (objectEntry
                  (slStringLiteral)
                  (functionLiteral
                    (parameterList
                      (typedIdentifier
                        (identifier)))
                    (methodCallExpr
                      (methodCallExpr
                        (variableExpr
                          (identifier))
                        (identifier)
                        (argumentList))
                      (identifier)
                      (argumentList
                        (functionLiteral
                          (parameterList
                            (typedIdentifier
                              (identifier)))
                          (objectLiteral
                            (parenthesizedExpr
                              (methodCallExpr
                                (variableExpr
                                  (identifier))
                                (identifier)
                                (argumentList
                                  (slStringLiteral))))
                            (objectBody
                              (objectElement
                                (objectLiteral
                                  (parenthesizedExpr
                                    (methodCallExpr
                                      (variableExpr
                                        (identifier))
                                      (identifier)
                                      (argumentList
                                        (propertyCallExpr
                                          (variableExpr
                                            (identifier))
                                          (identifier)))))
                                  (objectBody
                                    (objectElement
                                      (propertyCallExpr
                                        (variableExpr
                                          (identifier))
                                        (identifier)))))))))))))))))))))
