<commit_before>//$HeadURL: svn+ssh://ms<EMAIL>ider@svn.<EMAIL>.<EMAIL>.org/deegree/deegree3/trunk/deegree-services/deegree-services-commons/src/main/java/org/deegree/services/controller/ows/capabilities/OWSOperation.java $
/*----------------------------------------------------------------------------
 This file is part of deegree, http://deegree.org/
 Copyright (C) 2001-2011 by:
 Department of Geography, University of Bonn
 and
 lat/lon GmbH

 This library is free software; you can redistribute it and/or modify it under
 the terms of the GNU Lesser General Public License as published by the Free
 Software Foundation; either version 2.1 of the License, or (at your option)
 any later version.
 This library is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 details.
 You should have received a copy of the GNU Lesser General Public License
 along with this library; if not, write to the Free Software Foundation, Inc.,
 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

 Contact information:

 lat/lon GmbH
 Aennchenstr. 19, 53177 Bonn
 Germany
 http://lat-lon.de/

 Department of Geography, University of Bonn
 Prof. Dr. <NAME>
 Postfach 1147, 53001 Bonn
 Germany
 http://www.geographie.uni-bonn.de/deegree/

 e-mail: <EMAIL>
 ----------------------------------------------------------------------------*/
package org.deegree.services.ows.capabilities;

import static org.deegree.commons.xml.stax.XMLStreamUtils.copy;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;

import org.apache.axiom.om.OMElement;
import org.deegree.commons.ows.metadata.OperationsMetadata;
import org.deegree.commons.ows.metadata.ServiceIdentification;
import org.deegree.commons.ows.metadata.ServiceProvider;
import org.deegree.commons.ows.metadata.domain.AllowedValues;
import org.deegree.commons.ows.metadata.domain.AnyValue;
import org.deegree.commons.ows.metadata.domain.Domain;
import org.deegree.commons.ows.metadata.domain.NoValues;
import org.deegree.commons.ows.metadata.domain.PossibleValues;
import org.deegree.commons.ows.metadata.domain.Range;
import org.deegree.commons.ows.metadata.domain.Value;
import org.deegree.commons.ows.metadata.domain.Values;
import org.deegree.commons.ows.metadata.domain.ValuesReference;
import org.deegree.commons.ows.metadata.operation.DCP;
import org.deegree.commons.ows.metadata.operation.Operation;
import org.deegree.commons.ows.metadata.party.Address;
import org.deegree.commons.ows.metadata.party.ContactInfo;
import org.deegree.commons.ows.metadata.party.ResponsibleParty;
import org.deegree.commons.tom.ows.LanguageString;
import org.deegree.commons.tom.ows.Version;
import org.deegree.commons.utils.Pair;
import org.deegree.protocol.ows.OWSCommonXMLAdapter;
import org.deegree.services.jaxb.controller.DCPType;
import org.deegree.services.jaxb.metadata.AddressType;
import org.deegree.services.jaxb.metadata.CodeType;
import org.deegree.services.jaxb.metadata.KeywordsType;
import org.deegree.services.jaxb.metadata.LanguageStringType;
import org.deegree.services.jaxb.metadata.ServiceContactType;
import org.deegree.services.jaxb.metadata.ServiceIdentificationType;
import org.deegree.services.jaxb.metadata.ServiceProviderType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Provides methods for exporting
 * 
 * @author <a href="mailto:<EMAIL>"><NAME> </a>
 * @author last edited by: $Author:$
 * 
 * @version $Revision:$, $Date:$
 */
public class OWSCapabilitiesXMLAdapter extends OWSCommonXMLAdapter {

    private final static Logger LOG = LoggerFactory.getLogger( OWSCapabilitiesXMLAdapter.class );

    /**
     * Exports the given {@link ServiceIdentificationType} as an OWS 1.0.0 <code>ServiceIdentification</code> element.
     * 
     * @param writer
     *            used to append the XML, must not be <code>null</code>
     * @param serviceIdentification
     *            configuration object that provides most of the required metadata, must not be <code>null</code>
     * @param serviceName
     *            OGC-style abbreviation of the service, e.g. WFS, must not be <code>null</code>
     * @param serviceVersions
     *            supported protocol versions, must not be <code>null</code> and contain at least one entry
     * @throws XMLStreamException
     *             if writing the XML fails
     */
    public static void exportServiceIdentification100( XMLStreamWriter writer,
                                                       ServiceIdentification serviceIdentification,
                                                       final String serviceName, final List<Version> serviceVersions )
                            throws XMLStreamException {

        writer.writeStartElement( OWS_PREFIX, "ServiceIdentification", OWS_NS );
        if ( serviceIdentification.getTitle( null ) != null ) {
            // schema has maxOccurs=1, so only export the first entry
            writeElement( writer, OWS_NS, "Title", serviceIdentification.getTitle( null ).getString() );
        }
        if ( serviceIdentification.getAbstract( null ) != null ) {
            // schema has maxOccurs=1, so only export the first entry
            writeElement( writer, OWS_NS, "Abstract", serviceIdentification.getAbstract( null ).getString() );
        }
        if ( serviceIdentification.getKeywords() != null ) {
            for ( Pair<List<LanguageString>, org.deegree.commons.tom.ows.CodeType> keywords : serviceIdentification.getKeywords() ) {
                writer.writeStartElement( OWS_PREFIX, "Keywords", OWS_NS );
                for ( LanguageString keyword : keywords.first ) {
                    writeElement( writer, OWS_NS, "Keyword", keyword.getString() );
                }
                if ( keywords.second != null ) {
                    exportCodeTypeNew( writer, keywords.second, "Type", OWS_NS );
                }
                writer.writeEndElement();
            }
        }

        writeElement( writer, OWS_NS, "ServiceType", serviceName );
        exportVersions( writer, serviceVersions, OWS_NS, "ServiceTypeVersion" );

        if ( serviceIdentification.getFees() != null ) {
            writeElement( writer, OWS_NS, "Fees", serviceIdentification.getFees() );
        }

        exportSimpleStrings( writer, serviceIdentification.getAccessConstraints(), OWS_NS, "AccessConstraints" );
        writer.writeEndElement();
    }

    /**
     * Exports the given {@link ServiceIdentificationType} as an OWS 1.1.0 <code>ServiceIdentification</code> element.
     * 
     * @param writer
     *            used to append the XML, must not be <code>null</code>
     * @param serviceID
     *            configuration object that provides most of the required metadata, must not be <code>null</code>
     * @param serviceName
     *            OGC-style abbreviation of the service, e.g. WFS, must not be <code>null</code>
     * @param serviceVersions
     *            supported protocol versions, must not be <code>null</code> and contain at least one entry
     * @throws XMLStreamException
     *             if writing the XML fails
     */
    public static void exportServiceIdentification110New( XMLStreamWriter writer, ServiceIdentification serviceID,
                                                          final String serviceName, final List<Version> serviceVersions )
                            throws XMLStreamException {

        writer.writeStartElement( OWS110_NS, "ServiceIdentification" );
        if ( serviceID.getTitle( null ) != null ) {
            // schema has maxOccurs=1, so only export the first entry
            writeElement( writer, OWS110_NS, "Title", serviceID.getTitle( null ).getString() );
        }
        if ( serviceID.getAbstract( null ) != null ) {
            // schema has maxOccurs=1, so only export the first entry
            writeElement( writer, OWS110_NS, "Abstract", serviceID.getAbstract( null ).getString() );
        }
        exportKeyWords110New( writer, serviceID.getKeywords() );

        String srvn = serviceName;
        if ( serviceName == null || "".equals( serviceName ) ) {
            LOG.warn( "Service name may not be null, wrong call to exportServiceIdentification110, setting to unknown" );
            srvn = "unknown";
        }
        writeElement( writer, OWS110_NS, "ServiceType", srvn, null, null, "codeSpace", "http://www.opengeospatial.org/" );
        List<Version> versions = serviceVersions;
        if ( serviceVersions == null || serviceVersions.isEmpty() ) {
            LOG.warn( "Service versions name may not be null, wrong call to exportServiceIdentification110, setting to unknown" );
            versions = new ArrayList<Version>();
            versions.add( new Version( 1, 0, 0 ) );
        }

        exportVersions( writer, versions, OWS110_NS, "ServiceTypeVersion" );

        // No support for profiles ???
        if ( serviceID.getFees() != null && !"".equals( serviceID.getFees() ) ) {
            writeElement( writer, OWS110_NS, "Fees", serviceID.getFees() );
        }

        exportSimpleStrings( writer, serviceID.getAccessConstraints(), OWS110_NS, "AccessConstraints" );
        writer.writeEndElement();// OWS110_NS, ServiceIdentification
    }

    /**
     * Exports the given {@link ServiceIdentificationType} as an OWS 1.1.0 <code>ServiceIdentification</code> element.
     * 
     * @param writer
     *            used to append the XML, must not be <code>null</code>
     * @param serviceID
     *            configuration object that provides most of the required metadata, must not be <code>null</code>
     * @param serviceName
     *            OGC-style abbreviation of the service, e.g. WFS, must not be <code>null</code>
     * @param serviceVersions
     *            supported protocol versions, must not be <code>null</code> and contain at least one entry
     * @throws XMLStreamException
     *             if writing the XML fails
     */
    public static void exportServiceIdentification110( XMLStreamWriter writer, ServiceIdentificationType serviceID,
                                                       final String serviceName, final List<Version> serviceVersions )
                            throws XMLStreamException {

        writer.writeStartElement( OWS110_NS, "ServiceIdentification" );
        exportSimpleStrings( writer, serviceID.getTitle(), OWS110_NS, "Title" );
        exportSimpleStrings( writer, serviceID.getAbstract(), OWS110_NS, "Abstract" );
        exportKeyWords110( writer, serviceID.getKeywords() );

        String srvn = serviceName;
        if ( serviceName == null || "".equals( serviceName ) ) {
            LOG.warn( "Service name may not be null, wrong call to exportServiceIdentification110, setting to unknown" );
            srvn = "unknown";
        }
        writeElement( writer, OWS110_NS, "ServiceType", srvn );
        List<Version> versions = serviceVersions;
        if ( serviceVersions == null || serviceVersions.isEmpty() ) {
            LOG.warn( "Service versions name may not be null, wrong call to exportServiceIdentification110, setting to unknown" );
            versions = new ArrayList<Version>();
            versions.add( new Version( 1, 0, 0 ) );
        }

        exportVersions( writer, versions, OWS110_NS, "ServiceTypeVersion" );

        // No support for profiles ???
        if ( serviceID.getFees() != null && !"".equals( serviceID.getFees() ) ) {
            writeElement( writer, OWS110_NS, "Fees", serviceID.getFees() );
        }

        exportSimpleStrings( writer, serviceID.getAccessConstraints(), OWS110_NS, "AccessConstraints" );
        writer.writeEndElement();// OWS110_NS, ServiceIdentification
    }

    /**
     * Exports the given (commons) keywords to ows 1.1.0 format
     * 
     * @param writer
     * @param list
     * @throws XMLStreamException
     */
    public static void exportKeyWords110New( XMLStreamWriter writer,
                                             List<Pair<List<LanguageString>, org.deegree.commons.tom.ows.CodeType>> list )
                            throws XMLStreamException {
        if ( list != null && list.size() > 0 ) {
            for ( Pair<List<LanguageString>, org.deegree.commons.tom.ows.CodeType> keywords : list ) {
                writer.writeStartElement( OWS_PREFIX, "Keywords", OWS110_NS );
                for ( LanguageString keyword : keywords.first ) {
                    writeElement( writer, OWS110_NS, "Keyword", keyword.getString() );
                }
                if ( keywords.second != null ) {
                    exportCodeTypeNew( writer, keywords.second, "Type", OWS110_NS );
                }
                writer.writeEndElement();
            }
        }
    }

    /**
     * Exports the given (commons) keywords to ows 1.1.0 format
     * 
     * @param writer
     * @param keywords
     * @throws XMLStreamException
     */
    public static void exportKeyWords110( XMLStreamWriter writer, List<KeywordsType> keywords )
                            throws XMLStreamException {
        if ( keywords != null && keywords.size() > 0 ) {
            exportKeyWords( writer, keywords, OWS110_NS );
        }
    }

    /**
     * Exports a {@link ServiceProviderType} as an OWS 1.0.0 <code>ServiceProvider</code> element.
     * 
     * @param writer
     *            writer to append the xml
     * @param serviceProvider
     *            <code>ServiceProviderType</code> to export
     * @throws XMLStreamException
     */
    public static void exportServiceProvider100( XMLStreamWriter writer, ServiceProvider serviceProvider )
                            throws XMLStreamException {
        exportServiceProvider( writer, serviceProvider, OWS_NS );
    }

    /**
     * Exports a {@link ServiceProviderType} as an OWS 1.1.0 <code>ServiceProvider</code> element.
     * 
     * @param writer
     *            writer to append the xml
     * @param serviceProvider
     *            <code>ServiceProviderType</code> to export
     * @throws XMLStreamException
     */
    public static void exportServiceProvider110New( XMLStreamWriter writer, ServiceProvider serviceProvider )
                            throws XMLStreamException {
        exportServiceProvider( writer, serviceProvider, OWS110_NS );
    }

    /**
     * Exports a {@link ServiceProviderType} as an OWS 1.0.0 <code>ServiceProvider</code> element.
     * 
     * @param writer
     *            writer to append the xml
     * @param serviceProvider
     *            <code>ServiceProviderType</code> to export
     * @throws XMLStreamException
     */
    public static void exportServiceProvider100Old( XMLStreamWriter writer, ServiceProviderType serviceProvider )
                            throws XMLStreamException {
        String owsNS = OWS_NS;
        writer.writeStartElement( OWS_PREFIX, "ServiceProvider", owsNS );

        // ows:ProviderName (type="string")
        writer.writeStartElement( owsNS, "ProviderName" );
        writer.writeCharacters( serviceProvider.getProviderName() );
        writer.writeEndElement();

        if ( serviceProvider.getProviderSite() != null && !"".equals( serviceProvider.getProviderSite().trim() ) ) {
            // ows:ProviderSite (type="ows:OnlineResourceType")
            writer.writeStartElement( owsNS, "ProviderSite" );
            writer.writeAttribute( XLN_NS, "href", serviceProvider.getProviderSite() );
            writer.writeEndElement();
        }

        // ows:ProviderSite (type="ows:ResponsiblePartySubsetType")
        ServiceContactType serviceContact = serviceProvider.getServiceContact();<commit_msg>#959 - added null check if ServiceProvider is missing<commit_after>//$HeadURL: svn+ssh://<EMAIL>@svn.<EMAIL>/deegree/deegree3/trunk/deegree-services/deegree-services-commons/src/main/java/org/deegree/services/controller/ows/capabilities/OWSOperation.java $
/*----------------------------------------------------------------------------
 This file is part of deegree, http://deegree.org/
 Copyright (C) 2001-2011 by:
 Department of Geography, University of Bonn
 and
 lat/lon GmbH

 This library is free software; you can redistribute it and/or modify it under
 the terms of the GNU Lesser General Public License as published by the Free
 Software Foundation; either version 2.1 of the License, or (at your option)
 any later version.
 This library is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 details.
 You should have received a copy of the GNU Lesser General Public License
 along with this library; if not, write to the Free Software Foundation, Inc.,
 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

 Contact information:

 lat/lon GmbH
 Aennchenstr. 19, 53177 Bonn
 Germany
 http://lat-lon.de/

 Department of Geography, University of Bonn
 Prof. Dr. <NAME>
 Postfach 1147, 53001 Bonn
 Germany
 http://www.geographie.uni-bonn.de/deegree/

 e-mail: <EMAIL>
 ----------------------------------------------------------------------------*/
package org.deegree.services.ows.capabilities;

import static org.deegree.commons.xml.stax.XMLStreamUtils.copy;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;

import org.apache.axiom.om.OMElement;
import org.deegree.commons.ows.metadata.OperationsMetadata;
import org.deegree.commons.ows.metadata.ServiceIdentification;
import org.deegree.commons.ows.metadata.ServiceProvider;
import org.deegree.commons.ows.metadata.domain.AllowedValues;
import org.deegree.commons.ows.metadata.domain.AnyValue;
import org.deegree.commons.ows.metadata.domain.Domain;
import org.deegree.commons.ows.metadata.domain.NoValues;
import org.deegree.commons.ows.metadata.domain.PossibleValues;
import org.deegree.commons.ows.metadata.domain.Range;
import org.deegree.commons.ows.metadata.domain.Value;
import org.deegree.commons.ows.metadata.domain.Values;
import org.deegree.commons.ows.metadata.domain.ValuesReference;
import org.deegree.commons.ows.metadata.operation.DCP;
import org.deegree.commons.ows.metadata.operation.Operation;
import org.deegree.commons.ows.metadata.party.Address;
import org.deegree.commons.ows.metadata.party.ContactInfo;
import org.deegree.commons.ows.metadata.party.ResponsibleParty;
import org.deegree.commons.tom.ows.LanguageString;
import org.deegree.commons.tom.ows.Version;
import org.deegree.commons.utils.Pair;
import org.deegree.protocol.ows.OWSCommonXMLAdapter;
import org.deegree.services.jaxb.controller.DCPType;
import org.deegree.services.jaxb.metadata.AddressType;
import org.deegree.services.jaxb.metadata.CodeType;
import org.deegree.services.jaxb.metadata.KeywordsType;
import org.deegree.services.jaxb.metadata.LanguageStringType;
import org.deegree.services.jaxb.metadata.ServiceContactType;
import org.deegree.services.jaxb.metadata.ServiceIdentificationType;
import org.deegree.services.jaxb.metadata.ServiceProviderType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Provides methods for exporting
 * 
 * @author <a href="mailto:<EMAIL>"><NAME> </a>
 * @author last edited by: $Author:$
 * 
 * @version $Revision:$, $Date:$
 */
public class OWSCapabilitiesXMLAdapter extends OWSCommonXMLAdapter {

    private final static Logger LOG = LoggerFactory.getLogger( OWSCapabilitiesXMLAdapter.class );

    /**
     * Exports the given {@link ServiceIdentificationType} as an OWS 1.0.0 <code>ServiceIdentification</code> element.
     * 
     * @param writer
     *            used to append the XML, must not be <code>null</code>
     * @param serviceIdentification
     *            configuration object that provides most of the required metadata, must not be <code>null</code>
     * @param serviceName
     *            OGC-style abbreviation of the service, e.g. WFS, must not be <code>null</code>
     * @param serviceVersions
     *            supported protocol versions, must not be <code>null</code> and contain at least one entry
     * @throws XMLStreamException
     *             if writing the XML fails
     */
    public static void exportServiceIdentification100( XMLStreamWriter writer,
                                                       ServiceIdentification serviceIdentification,
                                                       final String serviceName, final List<Version> serviceVersions )
                            throws XMLStreamException {

        writer.writeStartElement( OWS_PREFIX, "ServiceIdentification", OWS_NS );
        if ( serviceIdentification.getTitle( null ) != null ) {
            // schema has maxOccurs=1, so only export the first entry
            writeElement( writer, OWS_NS, "Title", serviceIdentification.getTitle( null ).getString() );
        }
        if ( serviceIdentification.getAbstract( null ) != null ) {
            // schema has maxOccurs=1, so only export the first entry
            writeElement( writer, OWS_NS, "Abstract", serviceIdentification.getAbstract( null ).getString() );
        }
        if ( serviceIdentification.getKeywords() != null ) {
            for ( Pair<List<LanguageString>, org.deegree.commons.tom.ows.CodeType> keywords : serviceIdentification.getKeywords() ) {
                writer.writeStartElement( OWS_PREFIX, "Keywords", OWS_NS );
                for ( LanguageString keyword : keywords.first ) {
                    writeElement( writer, OWS_NS, "Keyword", keyword.getString() );
                }
                if ( keywords.second != null ) {
                    exportCodeTypeNew( writer, keywords.second, "Type", OWS_NS );
                }
                writer.writeEndElement();
            }
        }

        writeElement( writer, OWS_NS, "ServiceType", serviceName );
        exportVersions( writer, serviceVersions, OWS_NS, "ServiceTypeVersion" );

        if ( serviceIdentification.getFees() != null ) {
            writeElement( writer, OWS_NS, "Fees", serviceIdentification.getFees() );
        }

        exportSimpleStrings( writer, serviceIdentification.getAccessConstraints(), OWS_NS, "AccessConstraints" );
        writer.writeEndElement();
    }

    /**
     * Exports the given {@link ServiceIdentificationType} as an OWS 1.1.0 <code>ServiceIdentification</code> element.
     * 
     * @param writer
     *            used to append the XML, must not be <code>null</code>
     * @param serviceID
     *            configuration object that provides most of the required metadata, must not be <code>null</code>
     * @param serviceName
     *            OGC-style abbreviation of the service, e.g. WFS, must not be <code>null</code>
     * @param serviceVersions
     *            supported protocol versions, must not be <code>null</code> and contain at least one entry
     * @throws XMLStreamException
     *             if writing the XML fails
     */
    public static void exportServiceIdentification110New( XMLStreamWriter writer, ServiceIdentification serviceID,
                                                          final String serviceName, final List<Version> serviceVersions )
                            throws XMLStreamException {

        writer.writeStartElement( OWS110_NS, "ServiceIdentification" );
        if ( serviceID.getTitle( null ) != null ) {
            // schema has maxOccurs=1, so only export the first entry
            writeElement( writer, OWS110_NS, "Title", serviceID.getTitle( null ).getString() );
        }
        if ( serviceID.getAbstract( null ) != null ) {
            // schema has maxOccurs=1, so only export the first entry
            writeElement( writer, OWS110_NS, "Abstract", serviceID.getAbstract( null ).getString() );
        }
        exportKeyWords110New( writer, serviceID.getKeywords() );

        String srvn = serviceName;
        if ( serviceName == null || "".equals( serviceName ) ) {
            LOG.warn( "Service name may not be null, wrong call to exportServiceIdentification110, setting to unknown" );
            srvn = "unknown";
        }
        writeElement( writer, OWS110_NS, "ServiceType", srvn, null, null, "codeSpace", "http://www.opengeospatial.org/" );
        List<Version> versions = serviceVersions;
        if ( serviceVersions == null || serviceVersions.isEmpty() ) {
            LOG.warn( "Service versions name may not be null, wrong call to exportServiceIdentification110, setting to unknown" );
            versions = new ArrayList<Version>();
            versions.add( new Version( 1, 0, 0 ) );
        }

        exportVersions( writer, versions, OWS110_NS, "ServiceTypeVersion" );

        // No support for profiles ???
        if ( serviceID.getFees() != null && !"".equals( serviceID.getFees() ) ) {
            writeElement( writer, OWS110_NS, "Fees", serviceID.getFees() );
        }

        exportSimpleStrings( writer, serviceID.getAccessConstraints(), OWS110_NS, "AccessConstraints" );
        writer.writeEndElement();// OWS110_NS, ServiceIdentification
    }

    /**
     * Exports the given {@link ServiceIdentificationType} as an OWS 1.1.0 <code>ServiceIdentification</code> element.
     * 
     * @param writer
     *            used to append the XML, must not be <code>null</code>
     * @param serviceID
     *            configuration object that provides most of the required metadata, must not be <code>null</code>
     * @param serviceName
     *            OGC-style abbreviation of the service, e.g. WFS, must not be <code>null</code>
     * @param serviceVersions
     *            supported protocol versions, must not be <code>null</code> and contain at least one entry
     * @throws XMLStreamException
     *             if writing the XML fails
     */
    public static void exportServiceIdentification110( XMLStreamWriter writer, ServiceIdentificationType serviceID,
                                                       final String serviceName, final List<Version> serviceVersions )
                            throws XMLStreamException {

        writer.writeStartElement( OWS110_NS, "ServiceIdentification" );
        exportSimpleStrings( writer, serviceID.getTitle(), OWS110_NS, "Title" );
        exportSimpleStrings( writer, serviceID.getAbstract(), OWS110_NS, "Abstract" );
        exportKeyWords110( writer, serviceID.getKeywords() );

        String srvn = serviceName;
        if ( serviceName == null || "".equals( serviceName ) ) {
            LOG.warn( "Service name may not be null, wrong call to exportServiceIdentification110, setting to unknown" );
            srvn = "unknown";
        }
        writeElement( writer, OWS110_NS, "ServiceType", srvn );
        List<Version> versions = serviceVersions;
        if ( serviceVersions == null || serviceVersions.isEmpty() ) {
            LOG.warn( "Service versions name may not be null, wrong call to exportServiceIdentification110, setting to unknown" );
            versions = new ArrayList<Version>();
            versions.add( new Version( 1, 0, 0 ) );
        }

        exportVersions( writer, versions, OWS110_NS, "ServiceTypeVersion" );

        // No support for profiles ???
        if ( serviceID.getFees() != null && !"".equals( serviceID.getFees() ) ) {
            writeElement( writer, OWS110_NS, "Fees", serviceID.getFees() );
        }

        exportSimpleStrings( writer, serviceID.getAccessConstraints(), OWS110_NS, "AccessConstraints" );
        writer.writeEndElement();// OWS110_NS, ServiceIdentification
    }

    /**
     * Exports the given (commons) keywords to ows 1.1.0 format
     * 
     * @param writer
     * @param list
     * @throws XMLStreamException
     */
    public static void exportKeyWords110New( XMLStreamWriter writer,
                                             List<Pair<List<LanguageString>, org.deegree.commons.tom.ows.CodeType>> list )
                            throws XMLStreamException {
        if ( list != null && list.size() > 0 ) {
            for ( Pair<List<LanguageString>, org.deegree.commons.tom.ows.CodeType> keywords : list ) {
                writer.writeStartElement( OWS_PREFIX, "Keywords", OWS110_NS );
                for ( LanguageString keyword : keywords.first ) {
                    writeElement( writer, OWS110_NS, "Keyword", keyword.getString() );
                }
                if ( keywords.second != null ) {
                    exportCodeTypeNew( writer, keywords.second, "Type", OWS110_NS );
                }
                writer.writeEndElement();
            }
        }
    }

    /**
     * Exports the given (commons) keywords to ows 1.1.0 format
     * 
     * @param writer
     * @param keywords
     * @throws XMLStreamException
     */
    public static void exportKeyWords110( XMLStreamWriter writer, List<KeywordsType> keywords )
                            throws XMLStreamException {
        if ( keywords != null && keywords.size() > 0 ) {
            exportKeyWords( writer, keywords, OWS110_NS );
        }
    }

    /**
     * Exports a {@link ServiceProviderType} as an OWS 1.0.0 <code>ServiceProvider</code> element.
     * 
     * @param writer
     *            writer to append the xml
     * @param serviceProvider
     *            <code>ServiceProviderType</code> to export
     * @throws XMLStreamException
     */
    public static void exportServiceProvider100( XMLStreamWriter writer, ServiceProvider serviceProvider )
                            throws XMLStreamException {
        if ( serviceProvider != null ) {
            exportServiceProvider( writer, serviceProvider, OWS_NS );
        }
    }

    /**
     * Exports a {@link ServiceProviderType} as an OWS 1.1.0 <code>ServiceProvider</code> element.
     * 
     * @param writer
     *            writer to append the xml
     * @param serviceProvider
     *            <code>ServiceProviderType</code> to export
     * @throws XMLStreamException
     */
    public static void exportServiceProvider110New( XMLStreamWriter writer, ServiceProvider serviceProvider )
                            throws XMLStreamException {
        if ( serviceProvider != null ) {
            exportServiceProvider( writer, serviceProvider, OWS110_NS );
        }
    }

    /**
     * Exports a {@link ServiceProviderType} as an OWS 1.0.0 <code>ServiceProvider</code> element.
     * 
     * @param writer
     *            writer to append the xml
     * @param serviceProvider
     *            <code>ServiceProviderType</code> to export
     * @throws XMLStreamException
     */
    public static void exportServiceProvider100Old( XMLStreamWriter writer, ServiceProviderType serviceProvider )
                            throws XMLStreamException {
        String owsNS = OWS_NS;
        writer.writeStartElement( OWS_PREFIX, "ServiceProvider", owsNS );

        // ows:ProviderName (type="string")
        writer.writeStartElement( owsNS, "ProviderName" );
        writer.writeCharacters( serviceProvider.getProviderName() );
        writer.writeEndElement();

        if ( serviceProvider.getProviderSite() != null && !"".equals( serviceProvider.getProviderSite().trim() ) ) {
            // ows:ProviderSite (type="ows:OnlineResourceType")
            writer.writeStartElement( owsNS, "ProviderSite" );
            writer.writeAttribute( XLN_NS, "href", serviceProvider.getProviderSite() );
            writer.writeEndElement();
        }

        // ows:ProviderSite (type="ows:ResponsiblePartySubsetType")
        ServiceContactType serviceContact = serviceProvider.getServiceContact();
{'fraction_non_alphanumeric': 0.10583872792407768, 'fraction_numerical': 0.011658600967883855, 'mean_word_length': 2.5588235294117645, 'pattern_counts': {'":': 0, '<': 134, '<?xml version=': 0, '>': 138, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2660254', 'n_tokens_mistral': 8730, 'n_tokens_neox': 8326, 'n_words': 2234}