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

            writer.WriteStartElement(XacmlConstants.Prefixes.Policy, XacmlConstants.ElementNames.PolicyIdReference, 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 identifier reference_3_0.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns></returns>
        protected virtual XacmlContextPolicyIdReference ReadPolicyIdReference_3_0(XmlReader reader) {
            Contract.Requires<ArgumentNullException>(reader != null, "reader");
            Contract.Requires<XmlException>(reader.IsStartElement(XacmlConstants.ElementNames.PolicyIdReference, 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);

            XacmlContextPolicyIdReference result = new XacmlContextPolicyIdReference() {
                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;
        }