You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Sean Hoffman <se...@austintx.com> on 2002/12/11 13:20:08 UTC

Question: How do you create a new DOMDocument an include an already defined .dtd?

I was trying to do the following:

1.  get an implentation
		//	Get DOM implementation
		impl	=	DOMImplementationRegistry::getDOMImplementation(L"Core");

2.  Create a document type
			//	Create a documentType
//			docType	=   impl->createDocumentType( L"filterdb", NULL, L"filters.dtd" );

3.  Create the document
			if( docType )
			{
				DOMDocument	*doc=NULL;

				//	Create the document
				doc	=   impl->createDocument( NULL, WideString( pszFileName ).c_bstr(), docType );

			}



When I tried to create the document, however, I got no DOMDocument created.  I stepped into the code and saw that setDocumentType() is throwing an exception because the 
owner of the DOMDocumentType I created with the DOMImplementation object is not the same as the 'this' object, which is the new DOMDocument in construction.

A little further investigation noted that there's a createDocumentType method off DOMDocument.  This is cool, except now there's no way to set the name and systemId of the 
DOMDocumentType because there are accessor methods only on the DOMDocumentType.

I'm sure that others have done this before and it's something stupid I'm doing or something I'm overlooking.  I humbly ask this list for assistance.


Thanks



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Question: How do you create a new DOMDocument an include an already defined .dtd?

Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
	apoligies, I misread your mail. I will look at your patch this 
afternoon.


Gareth



On Wed, 11 Dec 2002, Sean Hoffman wrote:

> Actually, looking at http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-102161490, when doctype is NOT null, the node.ownerDocument attribute 
> should be set to the document being created.  In other words, unless I'm misunderstanding, the constructor of DOMDocument should set the the doctype's owner ot be the 
> DOMDocument itself.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> 

-- 
Gareth Reakes, Head of Product Development  +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Question: How do you create a new DOMDocument an include an already defined .dtd?

Posted by Sean Hoffman <se...@austintx.com>.
Actually, looking at http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-102161490, when doctype is NOT null, the node.ownerDocument attribute 
should be set to the document being created.  In other words, unless I'm misunderstanding, the constructor of DOMDocument should set the the doctype's owner ot be the 
DOMDocument itself.




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Question: How do you create a new DOMDocument an include an already defined .dtd?

Posted by Sean Hoffman <se...@austintx.com>.
Hmm, according to the docs I'm looking at, DOMDocumentType nodes can't be adopted.  Trying it in code throws an exception as well.

Even if this did work, i'm not getting a good grasp around what the purpose of doctype parameter on the DOMImplementation::createDocument method call. 



12/11/2002 7:03:04 AM, Gareth Reakes <ga...@decisionsoft.com> wrote:

>Hi,
>	you need to adopt the node into the document. Check out adoptNode 
>in DOMDocument
>
>Gareth
>
>On Wed, 11 Dec 2002, Sean Hoffman wrote:
>
>> I was trying to do the following:
>> 
>> 1.  get an implentation
>> 		//	Get DOM implementation
>> 		impl	=	DOMImplementationRegistry::getDOMImplementation(L"Core");
>> 
>> 2.  Create a document type
>> 			//	Create a documentType
>> //			docType	=   impl->createDocumentType( L"filterdb", NULL, L"filters.dtd" );
>> 
>> 3.  Create the document
>> 			if( docType )
>> 			{
>> 				DOMDocument	*doc=NULL;
>> 
>> 				//	Create the document
>> 				doc	=   impl->createDocument( NULL, WideString( pszFileName ).c_bstr(), docType );
>> 
>> 			}
>> 
>> 
>> 
>> When I tried to create the document, however, I got no DOMDocument created.  I stepped into the code and saw that setDocumentType() is throwing an exception because 
the 
>> owner of the DOMDocumentType I created with the DOMImplementation object is not the same as the 'this' object, which is the new DOMDocument in construction.
>> 
>> A little further investigation noted that there's a createDocumentType method off DOMDocument.  This is cool, except now there's no way to set the name and systemId of 
the 
>> DOMDocumentType because there are accessor methods only on the DOMDocumentType.
>> 
>> I'm sure that others have done this before and it's something stupid I'm doing or something I'm overlooking.  I humbly ask this list for assistance.
>> 
>> 
>> Thanks
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>> 
>> 
>
>-- 
>Gareth Reakes, Head of Product Development  +44-1865-203192
>DecisionSoft Limited                        http://www.decisionsoft.com
>XML Development and Services
>
>
>
>
>




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Question: How do you create a new DOMDocument an include an already defined .dtd?

Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
	you need to adopt the node into the document. Check out adoptNode 
in DOMDocument

Gareth

On Wed, 11 Dec 2002, Sean Hoffman wrote:

> I was trying to do the following:
> 
> 1.  get an implentation
> 		//	Get DOM implementation
> 		impl	=	DOMImplementationRegistry::getDOMImplementation(L"Core");
> 
> 2.  Create a document type
> 			//	Create a documentType
> //			docType	=   impl->createDocumentType( L"filterdb", NULL, L"filters.dtd" );
> 
> 3.  Create the document
> 			if( docType )
> 			{
> 				DOMDocument	*doc=NULL;
> 
> 				//	Create the document
> 				doc	=   impl->createDocument( NULL, WideString( pszFileName ).c_bstr(), docType );
> 
> 			}
> 
> 
> 
> When I tried to create the document, however, I got no DOMDocument created.  I stepped into the code and saw that setDocumentType() is throwing an exception because the 
> owner of the DOMDocumentType I created with the DOMImplementation object is not the same as the 'this' object, which is the new DOMDocument in construction.
> 
> A little further investigation noted that there's a createDocumentType method off DOMDocument.  This is cool, except now there's no way to set the name and systemId of the 
> DOMDocumentType because there are accessor methods only on the DOMDocumentType.
> 
> I'm sure that others have done this before and it's something stupid I'm doing or something I'm overlooking.  I humbly ask this list for assistance.
> 
> 
> Thanks
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> 

-- 
Gareth Reakes, Head of Product Development  +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org