// INTERNAL CONSTRUCTORS ////////////////////////////////////////////
        #region Constructors
        internal DocumentBuilder(DocumentWriter documentWriter,
                                 IHypermediaAssemblerRegistry hypermediaAssemblerRegistry,
                                 IHypermediaContext hypermediaContext,
                                 DocumentBuilderContext documentBuilderContext)
        {
            Contract.Requires(documentWriter != null);
            Contract.Requires(documentBuilderContext != null);

            var serviceModel = documentWriter.ServiceModel;
            var domDocument  = documentWriter.DomDocument;

            this.DomDocument    = domDocument;
            this.ServiceModel   = serviceModel;
            this.DocumentWriter = documentWriter;
            this.HypermediaAssemblerRegistry = hypermediaAssemblerRegistry;
            this.HypermediaContext           = hypermediaContext;
            this.DocumentBuilderContext      = documentBuilderContext;

            this.SetDocumentPathContextNodeAttribute();
        }
        private static IDocumentPathContext CreateDocumentPathContext(IHypermediaContext hypermediaContext, DocumentBuilderContext documentBuilderContext)
        {
            Contract.Requires(hypermediaContext != null);
            Contract.Requires(documentBuilderContext != null);

            var currentRequestUrl = documentBuilderContext.CurrentRequestUrl;

            if (currentRequestUrl == null)
            {
                return(null);
            }

            var documentPathContext = new DocumentPathContext(hypermediaContext, currentRequestUrl);

            return(documentPathContext);
        }