Generates an xml/encoding declaration
490830
public void serialize(Node src, net.oneandone.sushi.fs.Node dest, boolean format) throws IOException {
        // don't use Saver to allow transformer to decide about encoding */
        try (OutputStream out = dest.newOutputStream()) {
            serialize(new DOMSource(src), new StreamResult(out), dest.getWorld().getSettings().encoding, format);
        }
    }
1294790
def toxml(self):
        

        return '<ComponentReference name="{0}" type="{1}"'.format(self.name, self.type) + \
          (' local = "{0}"'.format(self.local) if self.local else '') + \
            '/>'
1348928
def xmldeclarations(self):
        """"""
        l = []
        E = ElementMaker(namespace="http://ilk.uvt.nl/folia",nsmap={None: "http://ilk.uvt.nl/folia", 'xml' : "http://www.w3.org/XML/1998/namespace"})

        for annotationtype, set in self.annotations:
            label = None
            #Find the 'label' for the declarations dynamically (aka: AnnotationType --> String)
            for key, value in vars(AnnotationType).items():
                if value == annotationtype:
                    label = key
                    break
            #gather attribs

            if (annotationtype == AnnotationType.TEXT or annotationtype == AnnotationType.PHON) and set == 'undefined' and len(self.annotationdefaults[annotationtype][set]) == 0:
                #this is the implicit TextContent declaration, no need to output it explicitly
                continue

            attribs = {}
            if set and set != 'undefined':
                attribs['{' + NSFOLIA + '}set'] = set


            for key, value in self.annotationdefaults[annotationtype][set].items():
                if key == 'annotatortype':
                    if value == AnnotatorType.MANUAL:
                        attribs['{' + NSFOLIA + '}' + key] = 'manual'
                    elif value == AnnotatorType.AUTO:
                        attribs['{' + NSFOLIA + '}' + key] = 'auto'
                elif key == 'datetime':
                    attribs['{' + NSFOLIA + '}' + key] = value.strftime("%Y-%m-%dT%H:%M:%S") #proper iso-formatting
                elif value:
                    attribs['{' + NSFOLIA + '}' + key] = value
            if label:
                l.append( makeelement(E,'{' + NSFOLIA + '}' + label.lower() + '-annotation', **attribs) )
            else:
                raise Exception("Invalid annotation type")
        return l
480172
public String toXml(Object root, String encoding) {
        try {
            StringWriter writer = new StringWriter();
            createMarshaller(encoding).marshal(root, writer);
            return writer.toString();
        } catch (JAXBException e) {
            throw new RuntimeException(e);
        }
    }
205946
def xml(self, indent = ""):
        """"""
        xml = indent + "<" + self.__class__.__name__
        xml += ' id="'+self.id + '"'
        xml += ' name="'+xmlescape(self.name) + '"'
        xml += ' description="'+xmlescape(self.description) + '"'
        if self.paramflag:
            xml += ' flag="'+self.paramflag + '"'
        for key, v in self.kwargs.items():
            if key not in ('value','error','name','description','flag','paramflag', 'validator'):
                if isinstance(v, bool):
                    xml += ' ' + key + '="' + str(int(v))+ '"'
                elif isinstance(v, list):
                    xml += ' ' + key + '="'+xmlescape(",".join(v))+ '"'
                elif isinstance(v, str)  or ( sys.version < '3' and isinstance(v, unicode)): #pylint: disable=undefined-variable
                    xml += ' ' + key + '="'+xmlescape(v)+ '"'
                else:
                    xml += ' ' + key + '="'+xmlescape(str(v))+ '"'
        if self.hasvalue:
            if sys.version < '3':
                xml += ' value="'+xmlescape(unicode(self.value)) + '"' #pylint: disable=undefined-variable
            else:
                xml += ' value="'+xmlescape(str(self.value)) + '"'
        if self.error:
            xml += ' error="'+xmlescape(self.error) + '"'
        xml += " />"
        return xml
1072227
void generateAntIvyXml(Definition def, String outputDir)
   {
      try
      {
         FileWriter antfw = Utils.createFile("build.xml", outputDir);
         BuildIvyXmlGen bxGen = new BuildIvyXmlGen();
         bxGen.generate(def, antfw);
         antfw.close();

         FileWriter ivyfw = Utils.createFile("ivy.xml", outputDir);
         IvyXmlGen ixGen = new IvyXmlGen();
         ixGen.generate(def, ivyfw);
         ivyfw.close();

         FileWriter ivySettingsfw = Utils.createFile("ivy.settings.xml", outputDir);
         IvySettingsXmlGen isxGen = new IvySettingsXmlGen();
         isxGen.generate(def, ivySettingsfw);
         ivySettingsfw.close();
      }
      catch (IOException ioe)
      {
         ioe.printStackTrace();
      }
   }
249202
def xml(self, indent = ""):
        """"""
        xml = indent + "<" + self.__class__.__name__
        xml += ' id="'+self.id + '"'
        xml += ' name="'+xmlescape(self.name) + '"'
        xml += ' description="'+xmlescape(self.description) + '"'
        if self.paramflag:
            xml += ' flag="'+self.paramflag + '"'
        if self.multi:
            xml += ' multi="true"'
        for key, value in self.kwargs.items():
            if key != 'choices' and key != 'default' and key != 'flag' and key != 'paramflag':
                if isinstance(value, bool):
                    xml += ' ' + key + '="' + str(int(value))+ '"'
                elif isinstance(value, list):
                    xml += ' ' + key + '="'+",".join(value)+ '"'
                else:
                    xml += ' ' + key + '="'+xmlescape(value)+ '"'
        if self.error:
            xml += ' error="'+self.error + '"'
        xml += ">"
        for key, value in self.choices:
            if self.value == key or (isinstance(self.value ,list) and key in self.value):
                xml += " <choice id=\""+key+"\" selected=\"1\">" + xmlescape(value) + "</choice>"
            else:
                xml += " <choice id=\""+key+"\">" + xmlescape(value) + "</choice>"
        xml += "</" + self.__class__.__name__ + ">"
        return xml
945560
def xml(self, operator='set', indent = ""):
        """"""
        xml = indent + "<meta id=\"" + self.key + "\""
        if operator != 'set':
            xml += " operator=\"" + operator + "\""
        if not self.value:
            xml += " />"
        else:
            xml += ">" + self.value + "</meta>"
        return xml
1237274
public String encode(XML xml) throws ParserException, SAXException, IOException {

        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = null;

        InputSource is = new InputSource(new StringReader(xml.toString()));

        try {
            builder = dbFactory.newDocumentBuilder();
            Document doc = builder.parse(is);
            return net.arnx.jsonic.JSON.encode(doc, true);
        } catch (SAXException e) {
            throw new ParserException(e.getMessage());
        } catch (ParserConfigurationException e) {
            throw new ParserException(e.getMessage());
        }
    }
95807
function XmlStream(stream, encoding) {
  events.EventEmitter.call(this);
  this._stream = stream;
  this._fa = new FiniteAutomata();
  this._lastState = 0;
  this._startState = {};
  this._finalStates = {};
  this._emitData = false;
  this._bufferLevel = 0;
  this._preserveLevel = 0;
  this._preserveWhitespace = 0;
  this._preserveAll = false;
  this._collect = false;
  this._parser = undefined;

  // Set input stream encoding and create an iconv instance,
  // if conversion is required. Default working encoding is UTF-8,
  // so iconv is used when input is anything else, but UTF-8.
  this._encoding = encoding || null;
  this._encoder = makeEncoder(this._encoding);

  var scope = this;

  // Start parsing.
  process.nextTick(function () {
    parse.call(scope);
  });
}
1265790
def xml(self, indent = ""):
        """"""
        xml = indent + "<InputTemplate id=\""+self.id+"\" format=\"" + self.formatclass.__name__ + "\"" + " label=\"" + self.label + "\""
        if self.formatclass.mimetype:
            xml +=" mimetype=\""+self.formatclass.mimetype+"\""
        if self.formatclass.schema:
            xml +=" schema=\""+self.formatclass.schema+"\""
        if self.filename:
            xml +=" filename=\""+self.filename+"\""
        if self.extension:
            xml +=" extension=\""+self.extension+"\""
        if self.optional:
            xml +=" optional=\"yes\""
        else:
            xml +=" optional=\"no\""
        if self.unique:
            xml +=" unique=\"yes\""
        else:
            xml +=" unique=\"no\""
        if self.acceptarchive:
            xml +=" acceptarchive=\"yes\""
        else:
            xml +=" acceptarchive=\"no\""
        xml += ">\n"
        for parameter in self.parameters:
            xml += parameter.xml(indent+"    ") + "\n"
        if self.converters:
            for converter in self.converters:
                xml += indent + "    <converter id=\""+converter.id+"\">"+clam.common.util.xmlescape(converter.label)+"</converter>\n"
        if self.inputsources:
            for inputsource in self.inputsources:
                xml += inputsource.xml(indent+"    ")
        xml += indent + "</InputTemplate>"
        return xml
444180
def output_xml(data, code, headers=None):
    """"""
    resp = make_response(dumps({'response' :data}), code)
    resp.headers.extend(headers or {})
    return resp
48872
def generate_xml
      values = { 
        'charset' => @options.charset,
        'files'   => gen_into(@files),
        'classes' => gen_into(@classes),
        'title'        => CGI.escapeHTML(@options.title),
      }
      
      # this method is defined in the template file
      write_extra_pages if defined? write_extra_pages

      template = TemplatePage.new(RDoc::Page::ONE_PAGE)

      if @options.op_name
        opfile = File.open(@options.op_name, "w")
      else
        opfile = $stdout
      end
      template.write_html_on(opfile, values)
    end
1090048
private static void generateParseOnXml(BindTypeContext context, BindEntity entity) {
		// @formatter:off
		MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("parseOnXml").addJavadoc("parse xml\n")
				.addAnnotation(Override.class).addModifiers(Modifier.PUBLIC)
				// .addParameter(typeName(KriptonXmlContext.class), "context")
				.addParameter(typeName(XMLParser.class), "xmlParser")
				.addParameter(typeName(Integer.TYPE), "currentEventType").returns(typeName(entity.getElement()))
				.addException(Exception.class);
		// @formatter:on

		boolean mutableObject = entity.isMutablePojo();

		if (mutableObject) {
			methodBuilder.addStatement("$T instance = new $T()", entity.getElement(), entity.getElement());
		} else {
			ImmutableUtility.generateImmutableVariableInit(entity, methodBuilder);
		}

		methodBuilder.addStatement("int eventType = currentEventType");
		methodBuilder.addStatement("boolean read=true");

		methodBuilder.addCode("\n");
		methodBuilder.beginControlFlow("if (currentEventType == 0)");
		methodBuilder.addStatement("eventType = xmlParser.next()");
		methodBuilder.nextControlFlow("else");
		methodBuilder.addStatement("eventType = xmlParser.getEventType()");
		methodBuilder.endControlFlow();
		methodBuilder.addStatement("String currentTag = xmlParser.getName().toString()");

		methodBuilder.addStatement("String elementName = currentTag");

		generateParseOnXmlAttributes(context, methodBuilder, entity);

		methodBuilder.addCode("\n");
		methodBuilder.addCode("//sub-elements\n");
		methodBuilder.beginControlFlow("while (xmlParser.hasNext() && elementName!=null)");

		methodBuilder.beginControlFlow("if (read)");
		methodBuilder.addStatement("eventType = xmlParser.next()");
		methodBuilder.nextControlFlow("else");
		methodBuilder.addStatement("eventType = xmlParser.getEventType()");
		methodBuilder.endControlFlow();
		methodBuilder.addStatement("read=true");

		methodBuilder.beginControlFlow("switch(eventType)$>");
		methodBuilder.addCode("case $T.START_TAG:\n$>", XmlPullParser.class);
		generateParserOnXmlStartElement(context, methodBuilder, "instance", "xmlParser", entity);
		methodBuilder.addStatement("$<break");

		methodBuilder.addCode("case $T.END_TAG:\n$>", XmlPullParser.class);
		generateParserOnXmlEndElement(context, methodBuilder, "instance", "xmlParser", entity);
		methodBuilder.addStatement("$<break");

		methodBuilder.addCode("case $T.CDSECT:\n", XmlPullParser.class);
		methodBuilder.addCode("case $T.TEXT:\n$>", XmlPullParser.class);
		generateParserOnXmlCharacters(context, methodBuilder, "instance", "xmlParser", entity);
		methodBuilder.addStatement("$<break");

		methodBuilder.addCode("default:\n$>");
		methodBuilder.addStatement("$<break");
		methodBuilder.addCode("$<");
		methodBuilder.endControlFlow();
		// @formatter:on

		methodBuilder.endControlFlow();

		if (!mutableObject) {
			ImmutableUtility.generateImmutableEntityCreation(entity, methodBuilder, "instance", true);
		}

		methodBuilder.addStatement("return instance");

		context.builder.addMethod(methodBuilder.build());
	}
1044167
function setup(encoding) {
  var stream = fs.createReadStream(path.join(__dirname, 'encoding.xml'));
  var xml = new XmlStream(stream, encoding);
  xml.on('endElement: node', function(node) {
    console.log(node);
  });
  xml.on('error', function(message) {
    console.log('Parsing as ' + (encoding || 'auto') + ' failed: ' + message);
  });
  return xml;
}
1045996
def to_xml(el):
    
    sio = StringIO()
    el.export(sio, 0, name_='PcGts', namespacedef_='xmlns:pc="%s"' % NAMESPACES['page'])
    return '<?xml version="1.0" encoding="UTF-8"?>\n' + sio.getvalue()
787180
public function generateXMLRequestString()
    {
        $enabledMetadataTypes = array();
        if ($this->enableSocialTags) {
            $enabledMetadataTypes[] = 'GenericRelations';
        }
        if ($this->enableGenericRelations) {
            $enabledMetadataTypes[] = 'SocialTags';
        }

        $xml  = '<c:params xmlns:c="http://s.opencalais.com/1/pred/" ';
        $xml .= 'xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">';
        $xml .= '<c:processingDirectives ';
        $xml .= 'c:contentType="' . $this->contentType . '" ';
        $xml .= 'c:enableMetadataType="' . implode(',', $enabledMetadataTypes) . '" ';
        $xml .= 'c:outputFormat="' . $this->outputFormat . '" ';
        $xml .= 'c:docRDFaccessible="' . ($this->docRDFaccessible ? 'true' : 'false') . '" ';
        $xml .= '></c:processingDirectives>';
        $xml .= '<c:userDirectives ';
        $xml .= 'c:allowDistribution="' . ($this->allowDistribution ? 'true' : 'false') . '" ';
        $xml .= 'c:allowSearch="' . ($this->allowSearch ? 'true' : 'false') . '" ';
        $xml .= '></c:userDirectives>';
        $xml .= '<c:externalMetadata></c:externalMetadata>';
        $xml .= '</c:params>';

        return $xml;
    }