You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Jakub Kahovec <j....@imperial.ac.uk> on 2004/11/30 15:43:14 UTC

Adding nodes to a PSVI generated document again

Hi,
I am trying to add new node to a PSVI generated document but the problem is that the node I am adding doesn't
have any schema information attached.
I'd tried to set the document 'psvi' and 'validate' fetures and then normalized document by calling method
normalizeDocument but despite this the new node still doesn't contain any schema information.

This si the piece of my code :

            Node node =  (Node) tree.getSelectionPath().getLastPathComponent();

            Node newNode = node.getOwnerDocument().createElement("NEW_NODE");
            newNode.appendChild( node.getOwnerDocument().createTextNode("NODE_TEXT"));

            node.getParentNode().appendChild(newNode);

	    node.getOwnerDocuemnt.getDomConfig().setParameter( "validate", Boolean.TRUE );
	    node.getOwnerDocuemnt.getDomConfig().setParameter( "psvi", Boolean.TRUE );

            node.getOwnerDocument().normalizeDocument();

            //!!!! node is without any schema schema information
	    node = node.getParentNode().getLastChild();



Thank you very much for any ideas.

Jakub


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


Re: Adding nodes to a PSVI generated document again

Posted by Jakub Kahovec <j....@imperial.ac.uk>.
Hi,
that was the cause of the problem, now it works well.

Thank you very much.

Jakub

Michael Glavassevich wrote:

>Hello Jakub,
>
>XML Schema depends on namespaces. The schema-aware nodes in the PSVI DOM 
>are all namespace-aware. Document.createElement() creates a 
>non-namespace-aware node. You should never use the DOM Level 1 
>non-namespace factory methods with a DOM containing namespace-aware nodes. 
>New element nodes should be created by calling Document.createElementNS() 
>[1].
>
>Hope that helps.
>
>[1] 
>http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-DocCrElNS
>
>Jakub Kahovec <j....@imperial.ac.uk> wrote on 11/30/2004 09:43:14 AM:
>
>  
>
>>Hi,
>>I am trying to add new node to a PSVI generated document but the 
>>problem is that the node I am adding doesn't
>>have any schema information attached.
>>I'd tried to set the document 'psvi' and 'validate' fetures and then
>>normalized document by calling method
>>normalizeDocument but despite this the new node still doesn't 
>>contain any schema information.
>>
>>This si the piece of my code :
>>
>>            Node node =  (Node) tree.getSelectionPath().
>>getLastPathComponent();
>>
>>            Node newNode = 
>>    
>>
>node.getOwnerDocument().createElement("NEW_NODE");
>  
>
>>            newNode.appendChild( node.getOwnerDocument().
>>createTextNode("NODE_TEXT"));
>>
>>            node.getParentNode().appendChild(newNode);
>>
>>       node.getOwnerDocuemnt.getDomConfig().setParameter( 
>>"validate", Boolean.TRUE );
>>       node.getOwnerDocuemnt.getDomConfig().setParameter( "psvi", 
>>Boolean.TRUE );
>>
>>            node.getOwnerDocument().normalizeDocument();
>>
>>            //!!!! node is without any schema schema information
>>       node = node.getParentNode().getLastChild();
>>
>>
>>
>>Thank you very much for any ideas.
>>
>>Jakub
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>>
>>    
>>
>
>Michael Glavassevich
>XML Parser Development
>IBM Toronto Lab
>E-mail: mrglavas@ca.ibm.com
>E-mail: mrglavas@apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
>  
>


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


Re: Adding nodes to a PSVI generated document again

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hello Jakub,

XML Schema depends on namespaces. The schema-aware nodes in the PSVI DOM 
are all namespace-aware. Document.createElement() creates a 
non-namespace-aware node. You should never use the DOM Level 1 
non-namespace factory methods with a DOM containing namespace-aware nodes. 
New element nodes should be created by calling Document.createElementNS() 
[1].

Hope that helps.

[1] 
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-DocCrElNS

Jakub Kahovec <j....@imperial.ac.uk> wrote on 11/30/2004 09:43:14 AM:

> Hi,
> I am trying to add new node to a PSVI generated document but the 
> problem is that the node I am adding doesn't
> have any schema information attached.
> I'd tried to set the document 'psvi' and 'validate' fetures and then
> normalized document by calling method
> normalizeDocument but despite this the new node still doesn't 
> contain any schema information.
> 
> This si the piece of my code :
> 
>             Node node =  (Node) tree.getSelectionPath().
> getLastPathComponent();
> 
>             Node newNode = 
node.getOwnerDocument().createElement("NEW_NODE");
>             newNode.appendChild( node.getOwnerDocument().
> createTextNode("NODE_TEXT"));
> 
>             node.getParentNode().appendChild(newNode);
> 
>        node.getOwnerDocuemnt.getDomConfig().setParameter( 
> "validate", Boolean.TRUE );
>        node.getOwnerDocuemnt.getDomConfig().setParameter( "psvi", 
> Boolean.TRUE );
> 
>             node.getOwnerDocument().normalizeDocument();
> 
>             //!!!! node is without any schema schema information
>        node = node.getParentNode().getLastChild();
> 
> 
> 
> Thank you very much for any ideas.
> 
> Jakub
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> 

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org


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