xerces-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alberto Massari <amass...@progress.com>
Subject Re: Writing documents with schemas and namespaces...
Date Wed, 21 Apr 2004 21:33:02 GMT
At 11.47 21/04/2004 -0400, Nick Bastin wrote:
>When writing out documents which have schemas and namespaces, am I 
>supposed to set up the createDocument() and createElement() calls 
>differently, or just add the attributes myself?
>
>For example, what code would I need to create:
>
><?xml version="1.0" encoding="UTF-8" standalone="no"?>
><ndr:Template xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>xmlns:ndr="http://www.opnet.com/ns/NetDoctor" 
>xsi:schemaLocation="http://www.opnet.com/ns/NetDoctor 
>/schemas/Report_Template?v11">
>   <...tags...>
></ndr:Template>
>
>I can read this file successfully, but I'm not having a lot of luck 
>writing it.  Now, I'm assuming that I'm not supposed to write those 
>attributes in directly, so maybe that's my problem.  Basically, the 
>question leads to - is there a lot of builtin support for writing 
>documents with schemas and namespaces, or do you just call createElement 
>with tags that already have their namespace qualifier in the name (like 
>"ndr:Template"), or do you call it with "Template" and you've already told 
>it a namespace?

The choice is up to you: you can use createElement("ndr:Template), but you 
also need to place the namespace definitions using 
setAttribute("xmlns:ndr","http://www.opnet.com/ns/NetDoctor"); or you use 
the DOM L2 API createElementNS("http://www.opnet.com/ns/NetDoctor", 
"ndr:Template") and the DOMWriter that will serialize it will create the 
(hopefully) right namespace declarations for you.

Alberto 



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


Mime
View raw message