/// <summary>
        /// Writes the policy set identifier reference.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="data">The data.</param>
        protected virtual void WritePolicySetIdReference(XmlWriter writer, XacmlContextPolicySetIdReference data) {
            Contract.Requires<ArgumentNullException>(writer != null);
            Contract.Requires<ArgumentNullException>(data != null);

            writer.WriteStartElement(XacmlConstants.Prefixes.Policy, XacmlConstants.ElementNames.PolicySetIdReference, this.version.NamespacePolicy);

            if (data.Version != null) {
                writer.WriteAttributeString(XacmlConstants.AttributeNames.Version, data.Version.ToString());
            }

            if (data.EarliestVersion != null) {
                writer.WriteAttributeString(XacmlConstants.AttributeNames.EarliestVersion, data.EarliestVersion.ToString());
            }

            if (data.LatestVersion != null) {
                writer.WriteAttributeString(XacmlConstants.AttributeNames.LatestVersion, data.LatestVersion.ToString());
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Reads the policy set identifier reference_3_0.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns></returns>
        protected virtual XacmlContextPolicySetIdReference ReadPolicySetIdReference_3_0(XmlReader reader) {
            Contract.Requires<ArgumentNullException>(reader != null, "reader");
            Contract.Requires<XmlException>(reader.IsStartElement(XacmlConstants.ElementNames.PolicySetIdReference, this.version.NamespaceContext));

            string version = this.ReadAttribute<string>(reader, XacmlConstants.AttributeNames.Version, isRequered: false);
            string earliestVersion = this.ReadAttribute<string>(reader, XacmlConstants.AttributeNames.EarliestVersion, isRequered: false);
            string latestVersion = this.ReadAttribute<string>(reader, XacmlConstants.AttributeNames.LatestVersion, isRequered: false);

            XacmlContextPolicySetIdReference result = new XacmlContextPolicySetIdReference() {
                Version = string.IsNullOrEmpty(version) ? null : new XacmlVersionMatchType(version),
                EarliestVersion = string.IsNullOrEmpty(earliestVersion) ? null : new XacmlVersionMatchType(earliestVersion),
                LatestVersion = string.IsNullOrEmpty(latestVersion) ? null : new XacmlVersionMatchType(latestVersion),
            };

            result.Value = reader.ReadInnerXml();
            return result;
        }