Writer

Component that outputs XML data to an OutputRange.

To format the XML data, it calls specific methods of the PrettyPrinter, if they are defined. Otherwise, it just prints the data with the minimal markup required. The currently available format callbacks are:

  • beforeNode, called as the first operation of outputting every XML node; expected to return a string to be printed before the node
  • afterNode, called as the last operation of outputting every XML node; expected to return a string to be printed after the node
  • increaseLevel, called after the start of a node that may have children (like a start tag or a doctype with an internal subset)
  • decreaseLevel, called before the end of a node that had some children (i.e. before writing a closing tag or the end of a doctype with an internal subset)
  • beforeAttributeName, called to obtain a string to be used as spacing between the tag name and the first attribute name and between the attribute value and the name of the next attribute; it is not used between the value of the last attribute and the closing >, nor between the tag name and the closing > if the element has no attributes
  • beforeElementEnd, called to obtain a string to be used as spacing before the closing > of a tag, that is after the last attribute name or after the tag name if the element has no attributes
  • afterAttributeName, called to obtain a string to be used as spacing between the name of an attribute and the = sign
  • beforeAttributeValue, called to obtain a string to be used as spacing between the = sign and the value of an attribute
  • formatAttribute(outputRange, attibuteValue), called to write out the value of an attribute
  • formatAttribute(attributeValue), called to obtain a string that represents the formatted attribute to be printed; used when the previous method is not defined
  • attributeDelimiter, called to obtain a string that represents the delimiter to be used when writing attributes; used when the previous two methods are not defined; in this case the attribute is not subject to any formatting, except prepending and appending the string returned by this method
  • afterCommentStart, called to obtain a string that represents the spacing to be used between the <!-- opening and the comment contents
  • beforeCommentEnd, called to obtain a string that represents the spacing to be used between the comment contents and the closing -->
  • betweenPITargetData, called to obtain a string to be used as spacing between the target and data of a processing instruction
  • beforePIEnd, called to obtain a string to be used as spacing between the processing instruction data and the closing ?>

Template arguments: _StringType = The type of string to be targeted. The function writeDOM will take care of all UTF conversion if necessary. PrettyPrinter = A struct, that will handle any and all formatting. validateTagOrder = If set to Yes, then tag order will be validated during writing.

Constructors

this
this(typeof(prettyPrinter) pretty)
Undocumented in source.

Members

Aliases

StringType
alias StringType = _StringType
Undocumented in source.

Functions

closeDoctype
void closeDoctype()
Undocumented in source. Be warned that the author may not have intended to support it.
closeElement
void closeElement(StringType tagName)
Undocumented in source. Be warned that the author may not have intended to support it.
startDoctype
void startDoctype(StringType content)
Undocumented in source. Be warned that the author may not have intended to support it.
startElement
void startElement(StringType tagName)
Undocumented in source. Be warned that the author may not have intended to support it.
writeAttribute
void writeAttribute(StringType name, StringType value)
Undocumented in source. Be warned that the author may not have intended to support it.
writeCDATA
void writeCDATA(StringType cdata)

Outputs a CDATA section with the given content.

writeComment
void writeComment(StringType comment)

Outputs a comment with the given content.

writeDeclaration
void writeDeclaration(StringType decl, StringType content)
Undocumented in source. Be warned that the author may not have intended to support it.
writeProcessingInstruction
void writeProcessingInstruction(StringType target, StringType data)

Outputs a processing instruction with the given target and data.

writeText
void writeText(StringType text)

Outputs a text node with the given content.

writeXMLDeclaration
void writeXMLDeclaration(Args args)

Outputs an XML declaration.

writeXMLDeclaration
void writeXMLDeclaration(StringType version_, StringType encoding, StringType standalone)
insideDTD
bool insideDTD;
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

output
StringType output;
Undocumented in source.
startingTag
bool startingTag;
Undocumented in source.

Meta