private static void addOutputLocationIfNotNull(XmlWriter xml, OutputLocation outputLocation) {
        if (outputLocation == null) {
            return;
        }

        xml.start("OutputLocation");
        if (outputLocation.getS3() != null) {
            S3Location s3 = outputLocation.getS3();
            xml.start("S3");

            addIfNotNull(xml, "BucketName", s3.getBucketName());
            addIfNotNull(xml, "Prefix", s3.getPrefix());

            if (s3.getEncryption() != null) {
                Encryption encryption = s3.getEncryption();
                xml.start("Encryption");
                addIfNotNull(xml, "EncryptionType", encryption.getEncryptionType());
                addIfNotNull(xml, "KMSKeyId", encryption.getKmsKeyId());
                addIfNotNull(xml, "KMSContext", encryption.getKmsContext());
                xml.end();
            }
            addIfNotNull(xml, "CannedACL", s3.getCannedACL());
            addGrantsIfNotNull(xml, s3.getAccessControlList());
            addTaggingIfNotNull(xml, s3.getTagging());
            addIfNotNull(xml, "StorageClass", s3.getStorageClass());

            addUserMetaDataIfNotNull(xml, s3.getUserMetadata());

            xml.end();
        }

        xml.end();
    }
Converts the SelectObjectContentRequest to an XML fragment that can be sent to
the SelectObjectContent operation of Amazon S3.
aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/model/transform/RequestXmlFactory.java