1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir #if defined(_MSC_VER) && (_MSC_VER > 1310) 28*cdf0e10cSrcweir #pragma warning(disable : 4701) 29*cdf0e10cSrcweir #endif 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "saxbuilder.hxx" 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <com/sun/star/xml/dom/XDocumentBuilder.hpp> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir namespace DOM 37*cdf0e10cSrcweir { 38*cdf0e10cSrcweir Reference< XInterface > CSAXDocumentBuilder::_getInstance(const Reference< XMultiServiceFactory >& rSMgr) 39*cdf0e10cSrcweir { 40*cdf0e10cSrcweir return static_cast< XSAXDocumentBuilder* >(new CSAXDocumentBuilder(rSMgr)); 41*cdf0e10cSrcweir } 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir const char* CSAXDocumentBuilder::aImplementationName = "com.sun.star.comp.xml.dom.SAXDocumentBuilder"; 44*cdf0e10cSrcweir const char* CSAXDocumentBuilder::aSupportedServiceNames[] = { 45*cdf0e10cSrcweir "com.sun.star.xml.dom.SAXDocumentBuilder", 46*cdf0e10cSrcweir NULL 47*cdf0e10cSrcweir }; 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir CSAXDocumentBuilder::CSAXDocumentBuilder(const Reference< XMultiServiceFactory >& mgr) 50*cdf0e10cSrcweir : m_aServiceManager(mgr) 51*cdf0e10cSrcweir , m_aState( SAXDocumentBuilderState_READY) 52*cdf0e10cSrcweir {} 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir OUString CSAXDocumentBuilder::_getImplementationName() 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir return OUString::createFromAscii(aImplementationName); 57*cdf0e10cSrcweir } 58*cdf0e10cSrcweir Sequence<OUString> CSAXDocumentBuilder::_getSupportedServiceNames() 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir Sequence<OUString> aSequence; 61*cdf0e10cSrcweir for (int i=0; aSupportedServiceNames[i]!=NULL; i++) { 62*cdf0e10cSrcweir aSequence.realloc(i+1); 63*cdf0e10cSrcweir aSequence[i]=(OUString::createFromAscii(aSupportedServiceNames[i])); 64*cdf0e10cSrcweir } 65*cdf0e10cSrcweir return aSequence; 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir Sequence< OUString > SAL_CALL CSAXDocumentBuilder::getSupportedServiceNames() 69*cdf0e10cSrcweir throw (RuntimeException) 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir return CSAXDocumentBuilder::_getSupportedServiceNames(); 72*cdf0e10cSrcweir } 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir OUString SAL_CALL CSAXDocumentBuilder::getImplementationName() 75*cdf0e10cSrcweir throw (RuntimeException) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir return CSAXDocumentBuilder::_getImplementationName(); 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir sal_Bool SAL_CALL CSAXDocumentBuilder::supportsService(const OUString& aServiceName) 81*cdf0e10cSrcweir throw (RuntimeException) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir Sequence< OUString > supported = CSAXDocumentBuilder::_getSupportedServiceNames(); 84*cdf0e10cSrcweir for (sal_Int32 i=0; i<supported.getLength(); i++) 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir if (supported[i] == aServiceName) return sal_True; 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir return sal_False; 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir SAXDocumentBuilderState SAL_CALL CSAXDocumentBuilder::getState() 93*cdf0e10cSrcweir throw (RuntimeException) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir ::osl::MutexGuard g(m_Mutex); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir return m_aState; 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir void SAL_CALL CSAXDocumentBuilder::reset() 101*cdf0e10cSrcweir throw (RuntimeException) 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir ::osl::MutexGuard g(m_Mutex); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir m_aDocument = Reference< XDocument >(); 106*cdf0e10cSrcweir m_aFragment = Reference< XDocumentFragment >(); 107*cdf0e10cSrcweir while (!m_aNodeStack.empty()) m_aNodeStack.pop(); 108*cdf0e10cSrcweir while (!m_aNSStack.empty()) m_aNSStack.pop(); 109*cdf0e10cSrcweir m_aState = SAXDocumentBuilderState_READY; 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir Reference< XDocument > SAL_CALL CSAXDocumentBuilder::getDocument() 113*cdf0e10cSrcweir throw (RuntimeException) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir ::osl::MutexGuard g(m_Mutex); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir if (m_aState != SAXDocumentBuilderState_DOCUMENT_FINISHED) 118*cdf0e10cSrcweir throw RuntimeException(); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir return m_aDocument; 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir Reference< XDocumentFragment > SAL_CALL CSAXDocumentBuilder::getDocumentFragment() 124*cdf0e10cSrcweir throw (RuntimeException) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir ::osl::MutexGuard g(m_Mutex); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir if (m_aState != SAXDocumentBuilderState_FRAGMENT_FINISHED) 129*cdf0e10cSrcweir throw RuntimeException(); 130*cdf0e10cSrcweir return m_aFragment; 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir void SAL_CALL CSAXDocumentBuilder::startDocumentFragment(const Reference< XDocument >& ownerDoc) 134*cdf0e10cSrcweir throw (RuntimeException) 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir ::osl::MutexGuard g(m_Mutex); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir // start a new document fragment and push it onto the stack 139*cdf0e10cSrcweir // we have to be in a clean state to do this 140*cdf0e10cSrcweir if (!m_aState == SAXDocumentBuilderState_READY) 141*cdf0e10cSrcweir throw RuntimeException(); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir m_aDocument = ownerDoc; 144*cdf0e10cSrcweir Reference< XDocumentFragment > aFragment = m_aDocument->createDocumentFragment(); 145*cdf0e10cSrcweir m_aNodeStack.push(Reference< XNode >(aFragment, UNO_QUERY)); 146*cdf0e10cSrcweir m_aFragment = aFragment; 147*cdf0e10cSrcweir m_aState = SAXDocumentBuilderState_BUILDING_FRAGMENT; 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir void SAL_CALL CSAXDocumentBuilder::endDocumentFragment() 151*cdf0e10cSrcweir throw (RuntimeException) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir ::osl::MutexGuard g(m_Mutex); 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir // there should only be the document left on the node stack 156*cdf0e10cSrcweir if (m_aState != SAXDocumentBuilderState_BUILDING_FRAGMENT) 157*cdf0e10cSrcweir throw RuntimeException(); 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir Reference< XNode > aNode = m_aNodeStack.top(); 160*cdf0e10cSrcweir if ( aNode->getNodeType() != NodeType_DOCUMENT_FRAGMENT_NODE) 161*cdf0e10cSrcweir throw RuntimeException(); 162*cdf0e10cSrcweir m_aNodeStack.pop(); 163*cdf0e10cSrcweir m_aState = SAXDocumentBuilderState_FRAGMENT_FINISHED; 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir // document handler 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir void SAL_CALL CSAXDocumentBuilder::startDocument() throw (RuntimeException, SAXException) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir ::osl::MutexGuard g(m_Mutex); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir // start a new document and push it onto the stack 173*cdf0e10cSrcweir // we have to be in a clean state to do this 174*cdf0e10cSrcweir if (!m_aState == SAXDocumentBuilderState_READY) 175*cdf0e10cSrcweir throw SAXException(); 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir Reference< XDocumentBuilder > aBuilder(m_aServiceManager->createInstance( 178*cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.xml.dom.DocumentBuilder")), UNO_QUERY_THROW); 179*cdf0e10cSrcweir Reference< XDocument > aDocument = aBuilder->newDocument(); 180*cdf0e10cSrcweir m_aNodeStack.push(Reference< XNode >(aDocument, UNO_QUERY)); 181*cdf0e10cSrcweir m_aDocument = aDocument; 182*cdf0e10cSrcweir m_aState = SAXDocumentBuilderState_BUILDING_DOCUMENT; 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir void SAL_CALL CSAXDocumentBuilder::endDocument() throw (RuntimeException, SAXException) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir ::osl::MutexGuard g(m_Mutex); 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir // there should only be the document left on the node stack 190*cdf0e10cSrcweir if (!m_aState == SAXDocumentBuilderState_BUILDING_DOCUMENT) 191*cdf0e10cSrcweir throw SAXException(); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir Reference< XNode > aNode = m_aNodeStack.top(); 194*cdf0e10cSrcweir if ( aNode->getNodeType() != NodeType_DOCUMENT_NODE) 195*cdf0e10cSrcweir throw SAXException(); 196*cdf0e10cSrcweir m_aNodeStack.pop(); 197*cdf0e10cSrcweir m_aState = SAXDocumentBuilderState_DOCUMENT_FINISHED; 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir void SAL_CALL CSAXDocumentBuilder::startElement(const OUString& aName, const Reference< XAttributeList>& attribs) 201*cdf0e10cSrcweir throw (RuntimeException, SAXException) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir ::osl::MutexGuard g(m_Mutex); 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir if ( m_aState != SAXDocumentBuilderState_BUILDING_DOCUMENT && 206*cdf0e10cSrcweir m_aState != SAXDocumentBuilderState_BUILDING_FRAGMENT) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir throw SAXException(); 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir // start with mappings in effect for last level 212*cdf0e10cSrcweir NSMap aNSMap; 213*cdf0e10cSrcweir if (!m_aNSStack.empty()) 214*cdf0e10cSrcweir aNSMap = NSMap(m_aNSStack.top()); 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir // handle xmlns: attributes and add to mappings 217*cdf0e10cSrcweir OUString attr_qname; 218*cdf0e10cSrcweir OUString attr_value; 219*cdf0e10cSrcweir OUString newprefix; 220*cdf0e10cSrcweir AttrMap aAttrMap; 221*cdf0e10cSrcweir sal_Int32 idx=-1; 222*cdf0e10cSrcweir sal_Int16 nAttributes = attribs->getLength(); 223*cdf0e10cSrcweir for (sal_Int16 i=0; i<nAttributes; i++) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir attr_qname = attribs->getNameByIndex(i); 226*cdf0e10cSrcweir attr_value = attribs->getValueByIndex(i); 227*cdf0e10cSrcweir // new prefix mapping 228*cdf0e10cSrcweir if (attr_qname.indexOf(OUString::createFromAscii("xmlns:")) == 0) 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir newprefix = attr_qname.copy(attr_qname.indexOf(':')+1); 231*cdf0e10cSrcweir aNSMap.insert(NSMap::value_type(newprefix, attr_value)); 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir else if (attr_qname == OUString::createFromAscii("xmlns")) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir // new default prefix 236*cdf0e10cSrcweir aNSMap.insert(NSMap::value_type(OUString(), attr_value)); 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir else 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir aAttrMap.insert(AttrMap::value_type(attr_qname, attr_value)); 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir // does the element have a prefix? 245*cdf0e10cSrcweir OUString aPrefix; 246*cdf0e10cSrcweir OUString aURI; 247*cdf0e10cSrcweir Reference< XElement > aElement; 248*cdf0e10cSrcweir idx = aName.indexOf(':'); 249*cdf0e10cSrcweir if (idx != -1) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir aPrefix = aName.copy(0, idx); 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir else 254*cdf0e10cSrcweir aPrefix = OUString(); 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir NSMap::const_iterator result = aNSMap.find(aPrefix); 257*cdf0e10cSrcweir if ( result != aNSMap.end()) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir // found a URI for prefix 260*cdf0e10cSrcweir // qualified name 261*cdf0e10cSrcweir aElement = m_aDocument->createElementNS( result->second, aName); 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir else 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir // no URI for prefix 266*cdf0e10cSrcweir aElement = m_aDocument->createElement(aName); 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir aElement = Reference< XElement > ( 269*cdf0e10cSrcweir m_aNodeStack.top()->appendChild(Reference< XNode >(aElement, UNO_QUERY)), 270*cdf0e10cSrcweir UNO_QUERY); 271*cdf0e10cSrcweir m_aNodeStack.push(Reference< XNode >(aElement, UNO_QUERY)); 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir // set non xmlns attributes 274*cdf0e10cSrcweir aPrefix = OUString(); 275*cdf0e10cSrcweir aURI = OUString(); 276*cdf0e10cSrcweir AttrMap::const_iterator a = aAttrMap.begin(); 277*cdf0e10cSrcweir while (a != aAttrMap.end()) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir attr_qname = a->first; 280*cdf0e10cSrcweir attr_value = a->second; 281*cdf0e10cSrcweir idx = attr_qname.indexOf(':'); 282*cdf0e10cSrcweir if(idx != -1) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir aPrefix = attr_qname.copy(0, idx); 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir else 287*cdf0e10cSrcweir aPrefix = OUString(); 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir result = aNSMap.find(aPrefix); 290*cdf0e10cSrcweir if (result != aNSMap.end()) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir // set attribute with namespace 293*cdf0e10cSrcweir aElement->setAttributeNS(result->second, attr_qname, attr_value); 294*cdf0e10cSrcweir } else { 295*cdf0e10cSrcweir // set attribute without namespace 296*cdf0e10cSrcweir aElement->setAttribute(attr_qname, attr_value); 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir a++; 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir m_aNSStack.push(aNSMap); 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir void SAL_CALL CSAXDocumentBuilder::endElement(const OUString& aName) 304*cdf0e10cSrcweir throw (RuntimeException, SAXException) 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir ::osl::MutexGuard g(m_Mutex); 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir // pop the current element from the stack 309*cdf0e10cSrcweir if ( m_aState != SAXDocumentBuilderState_BUILDING_DOCUMENT && 310*cdf0e10cSrcweir m_aState != SAXDocumentBuilderState_BUILDING_FRAGMENT) 311*cdf0e10cSrcweir throw SAXException(); 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir Reference< XNode > aNode(m_aNodeStack.top()); 314*cdf0e10cSrcweir if (aNode->getNodeType() != NodeType_ELEMENT_NODE) 315*cdf0e10cSrcweir throw SAXException(); 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir Reference< XElement > aElement(aNode, UNO_QUERY); 318*cdf0e10cSrcweir OUString aRefName; 319*cdf0e10cSrcweir OUString aPrefix = aElement->getPrefix(); 320*cdf0e10cSrcweir if (aPrefix.getLength() > 0) 321*cdf0e10cSrcweir aRefName = aPrefix + OUString::createFromAscii(":") + aElement->getTagName(); 322*cdf0e10cSrcweir else 323*cdf0e10cSrcweir aRefName = aElement->getTagName(); 324*cdf0e10cSrcweir if (aRefName != aName) // consistency check 325*cdf0e10cSrcweir throw SAXException(); 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir // pop it 328*cdf0e10cSrcweir m_aNodeStack.pop(); 329*cdf0e10cSrcweir m_aNSStack.pop(); 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir void SAL_CALL CSAXDocumentBuilder::characters(const OUString& aChars) 333*cdf0e10cSrcweir throw (RuntimeException, SAXException) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir ::osl::MutexGuard g(m_Mutex); 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir // append text node to the current top element 338*cdf0e10cSrcweir if (m_aState != SAXDocumentBuilderState_BUILDING_DOCUMENT && 339*cdf0e10cSrcweir m_aState != SAXDocumentBuilderState_BUILDING_FRAGMENT) 340*cdf0e10cSrcweir throw SAXException(); 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir Reference< XText > aText = m_aDocument->createTextNode(aChars); 343*cdf0e10cSrcweir m_aNodeStack.top()->appendChild(Reference< XNode >(aText, UNO_QUERY)); 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir void SAL_CALL CSAXDocumentBuilder::ignorableWhitespace(const OUString& ) 347*cdf0e10cSrcweir throw (RuntimeException, SAXException) 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir ::osl::MutexGuard g(m_Mutex); 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir // ignore ignorable whitespace 352*cdf0e10cSrcweir if ( m_aState != SAXDocumentBuilderState_BUILDING_DOCUMENT && 353*cdf0e10cSrcweir m_aState != SAXDocumentBuilderState_BUILDING_FRAGMENT) 354*cdf0e10cSrcweir throw SAXException(); 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir void SAL_CALL CSAXDocumentBuilder::processingInstruction(const OUString& aTarget, const OUString& aData) 358*cdf0e10cSrcweir throw (RuntimeException, SAXException) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir ::osl::MutexGuard g(m_Mutex); 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir // append PI node to the current top 363*cdf0e10cSrcweir if ( m_aState != SAXDocumentBuilderState_BUILDING_DOCUMENT && 364*cdf0e10cSrcweir m_aState != SAXDocumentBuilderState_BUILDING_FRAGMENT) 365*cdf0e10cSrcweir throw SAXException(); 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir Reference< XProcessingInstruction > aInstruction = m_aDocument->createProcessingInstruction( 368*cdf0e10cSrcweir aTarget, aData); 369*cdf0e10cSrcweir m_aNodeStack.top()->appendChild(Reference< XNode >(aInstruction, UNO_QUERY)); 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir void SAL_CALL CSAXDocumentBuilder::setDocumentLocator(const Reference< XLocator >& aLocator) 373*cdf0e10cSrcweir throw (RuntimeException, SAXException) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir ::osl::MutexGuard g(m_Mutex); 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir // set the document locator... 378*cdf0e10cSrcweir m_aLocator = aLocator; 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir } 381