445
445
delete fElements;
449
WFXMLScanner::resolvePrefix(const XMLCh* const prefix
450
, const ElemStack::MapModes mode)
452
// Watch for the special namespace prefixes. We always map these to
453
// special URIs. 'xml' gets mapped to the official URI that its defined
454
// to map to by the NS spec. xmlns gets mapped to a special place holder
455
// URI that we define (so that it maps to something checkable.)
456
if (XMLString::equals(prefix, XMLUni::fgXMLNSString))
457
return fXMLNSNamespaceId;
458
else if (XMLString::equals(prefix, XMLUni::fgXMLString))
459
return fXMLNamespaceId;
461
// Ask the element stack to search up itself for a mapping for the
464
unsigned int uriId = fElemStack.mapPrefixToURI(prefix, mode, unknown);
466
// If it was unknown, then the URI was faked in but we have to issue an error
468
emitError(XMLErrs::UnknownPrefix, prefix);
470
// check to see if uriId is empty; in XML 1.1 an emptynamespace is okay unless
471
// we are trying to use it.
473
mode == ElemStack::Mode_Element &&
474
fXMLVersion != XMLReader::XMLV1_0 &&
475
uriId == fElemStack.getEmptyNamespaceId())
476
emitError(XMLErrs::UnknownPrefix, prefix);
481
448
// This method will reset the scanner data structures, and related plugged
482
449
// in stuff, for a new scan session. We get the input source for the primary
483
450
// XML entity, create the reader for it, and push it on the stack so that
840
808
if ((nextCh != chForwardSlash) && (nextCh != chCloseAngle))
842
if (fReaderMgr.getCurrentReader()->isWhitespace(nextCh))
844
// Ok, skip by them and peek another char
845
fReaderMgr.skipPastSpaces();
846
nextCh = fReaderMgr.peekNextChar();
811
fReaderMgr.skipPastSpaces(bFoundSpace);
850
814
// Emit the error but keep on going
851
815
emitError(XMLErrs::ExpectedWhitespace);
817
// Ok, peek another char
818
nextCh = fReaderMgr.peekNextChar();
1171
1137
if ((nextCh != chForwardSlash) && (nextCh != chCloseAngle))
1173
if (fReaderMgr.getCurrentReader()->isWhitespace(nextCh))
1175
// Ok, skip by them and peek another char
1176
fReaderMgr.skipPastSpaces();
1177
nextCh = fReaderMgr.peekNextChar();
1140
fReaderMgr.skipPastSpaces(bFoundSpace);
1181
1143
// Emit the error but keep on going
1182
1144
emitError(XMLErrs::ExpectedWhitespace);
1146
// Ok, peek another char
1147
nextCh = fReaderMgr.peekNextChar();
1542
WFXMLScanner::resolveQName(const XMLCh* const qName
1543
, XMLBuffer& prefixBuf
1545
, int& prefixColonPos)
1547
// Lets split out the qName into a URI and name buffer first. The URI
1549
prefixColonPos = XMLString::indexOf(qName, chColon);
1550
if (prefixColonPos == -1)
1552
// Its all name with no prefix, so put the whole thing into the name
1553
// buffer. Then map the empty string to a URI, since the empty string
1554
// represents the default namespace. This will either return some
1555
// explicit URI which the default namespace is mapped to, or the
1556
// the default global namespace.
1557
bool unknown = false;
1560
return fElemStack.mapPrefixToURI(XMLUni::fgZeroLenString, (ElemStack::MapModes) mode, unknown);
1564
// Copy the chars up to but not including the colon into the prefix
1566
prefixBuf.set(qName, prefixColonPos);
1568
// Watch for the special namespace prefixes. We always map these to
1569
// special URIs. 'xml' gets mapped to the official URI that its defined
1570
// to map to by the NS spec. xmlns gets mapped to a special place holder
1571
// URI that we define (so that it maps to something checkable.)
1572
const XMLCh* prefixRawBuf = prefixBuf.getRawBuffer();
1573
if (XMLString::equals(prefixRawBuf, XMLUni::fgXMLNSString)) {
1575
// if this is an element, it is an error to have xmlns as prefix
1576
if (mode == ElemStack::Mode_Element)
1577
emitError(XMLErrs::NoXMLNSAsElementPrefix, qName);
1579
return fXMLNSNamespaceId;
1581
else if (XMLString::equals(prefixRawBuf, XMLUni::fgXMLString)) {
1582
return fXMLNamespaceId;
1586
bool unknown = false;
1587
unsigned int uriId = fElemStack.mapPrefixToURI(prefixRawBuf, (ElemStack::MapModes) mode, unknown);
1590
emitError(XMLErrs::UnknownPrefix, prefixRawBuf);
1597
1505
// ---------------------------------------------------------------------------
1598
1506
// XMLScanner: Private parsing methods
1599
1507
// ---------------------------------------------------------------------------