That's because Xalan's source trees are read only.  If you need to
read/modify a source tree, using a Xerces document is probably the way to
go.  If you just need to build a document, you can use a
FormatterToSourceTree and build with SAX events.

> -----Original Message-----
> From: Ashay Shende [mailto:[EMAIL PROTECTED]
> Sent: 18 March 2003 08:18
> To: [email protected]
> Subject: using Xalan to parse an XML document.
> Importance: High
>
>
> Hi,
> This is regarding the use of Xalan for parsing an XML document.
>
>
> The DOM is of type XalanDocument(variable:theDocument)
>
> When I try to create a new element using :
> theDocument->createElement(elemName).....elemName is of type
> XalanDOMString,
> the code compiles without any syntax errors.
>
> However, when I run the application, I get an Exception of code=9
> (NOT_SUPPORTED_ERR) at the statement:
> theDocument->createElement(elemName).
>
> **********The Code*********************************************
> try
>     {
>            XMLPlatformUtils::Initialize();
>
>               XPathEvaluator::initialize();
>             {
>                // Initialize the XalanSourceTree subsystem...
>                XalanSourceTreeInit             theSourceTreeInit;
>                // We'll use these to parse the XML file.
>                XalanSourceTreeDOMSupport               theDOMSupport;
>                XalanSourceTreeParserLiaison    theLiaison(theDOMSupport);
>
>                // Hook the two together...
>                       theDOMSupport.setParserLiaison(&theLiaison);
>
>                // Create an input source that represents a local file...
>               const LocalFileInputSource
> theInputSource(c_wstr(XalanDOMString(file_name)));
>
>                // Parse the document...
>                  XalanDocument*  theDocument =
> theLiaison.parseXMLStream(theInputSource);
>                  assert(theDocument != 0);
>
>                  cout << "Before Ceating new Element1" << "\n";
>
>                   XalanDOMString
> ename(XALAN_STATIC_UCODE_STRING("Elem1"));
>                   XalanElement* newElem =
> theDocument->createElement(ename);
>
>                   cout << "After creating new Element1" << "\n";
>
>               }
>
>       }
>       catch(const XalanDOMException& toCatch)
>       {
>            cout << "Exception:" << toCatch.getExceptionCode() << "\n";
>       }
>
> ******************************************************************
> **********
> *******
>
> The Output:
> Before Creating New Element1
> Exception:9
>
>
> This exception is raised "if the implementation does not support the
> requested type object or operation."
>
> Could someone give me pointers as to what the code is missing in detail.
>
>
> Thanks,
> Ashay.
>
>
>

Reply via email to