 @_exported import struct SemVer.Version
 
+/// Represents options to use for serializing xml elements.
 public struct SerializationOptions: OptionSet {
    public typealias RawValue = Int
    

}

public extension String {
   public func escaped(content: EscapableContent) -> String {
      return content.replacements.reduce(self) {
         $0.replacingOccurrences(of: $1.unescaped, with: $1.escaped)
      }
   }
   
   public mutating func escape(content: EscapableContent) {
      self = escaped(content: content)
   }
}

public extension String {
    public init(xmlDocumentRoot root: Element, version: Version = Version(major: 1), encoding: DocumentEncoding = .utf8, options: SerializationOptions = []) {
      let versionAttribute = "version=" + options.quotes.quoted(attributeString: version.xmlVersionString)
      let encodingAttribute = "encoding=" + options.quotes.quoted(attributeString: encoding.attributeValue)

         + String(xml: root, options: options)
   }
   
   /// Creates a String by serializing an xml element.
   ///
   /// - Parameters:
   ///   - xml: The xml element to serialize.
   ///   - options: The options to use for serializing. Defaults to empty options.
   public init(xml: Element, options: SerializationOptions = []) {
      let attributes = xml.attributes.isEmpty ? "" : " " + xml.attributes.map {
         $0.key + "=" + options.quotes.quoted(attributeString: $0.value)
