org.apache.xerces.xni.QName Java Examples

The following examples show how to use org.apache.xerces.xni.QName. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HTMLTagBalancer.java    From cc-dbp with Apache License 2.0 6 votes vote down vote up
/** Resets the component. */
public void reset(XMLComponentManager manager)
    throws XMLConfigurationException {

    // get features
    fNamespaces = manager.getFeature(NAMESPACES);
    fAugmentations = manager.getFeature(AUGMENTATIONS);
    fReportErrors = manager.getFeature(REPORT_ERRORS);
    fDocumentFragment = manager.getFeature(DOCUMENT_FRAGMENT) ||
                        manager.getFeature(DOCUMENT_FRAGMENT_DEPRECATED);
    fIgnoreOutsideContent = manager.getFeature(IGNORE_OUTSIDE_CONTENT);

    // get properties
    fNamesElems = getNamesValue(String.valueOf(manager.getProperty(NAMES_ELEMS)));
    fNamesAttrs = getNamesValue(String.valueOf(manager.getProperty(NAMES_ATTRS)));
    fErrorReporter = (HTMLErrorReporter)manager.getProperty(ERROR_REPORTER);
    
    fragmentContextStack_ = (QName[]) manager.getProperty(FRAGMENT_CONTEXT_STACK);

}
 
Example #2
Source File: HTMLTagBalancer.java    From cc-dbp with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an element information object.
 * <p>
 * <strong>Note:</strong>
 * This constructor makes a copy of the element information.
 *
 * @param element The element qualified name.
 * @param attributes The element attributes.
 */
public Info(HTMLElements.Element element,
            QName qname, XMLAttributes attributes) {
    this.element = element;
    this.qname = new QName(qname);
    if (attributes != null) {
        int length = attributes.getLength();
        if (length > 0) {
            QName aqname = new QName();
            XMLAttributes newattrs = new XMLAttributesImpl();
            for (int i = 0; i < length; i++) {
                attributes.getName(i, aqname);
                String type = attributes.getType(i);
                String value = attributes.getValue(i);
                String nonNormalizedValue = attributes.getNonNormalizedValue(i);
                boolean specified = attributes.isSpecified(i);
                newattrs.addAttribute(aqname, type, value);
                newattrs.setNonNormalizedValue(i, nonNormalizedValue);
                newattrs.setSpecified(i, specified);
            }
            this.attributes = newattrs;
        }
    }
}
 
Example #3
Source File: TmxScanner.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
private void appendErrorCode() throws IOException {
	QName qName = fCurrentElement;
	XMLAttributesImpl attr = fAttributes;

	StringBuilder builder = new StringBuilder();
	builder.append('<').append(qName.rawname);
	for (int i = 0; i < attr.getLength(); i++) {
		builder.append(' ').append(attr.getQName(i)).append('=').append('\"').append(attr.getValue(i)).append('\"');
	}
	builder.append('>');

	errorCode.append(builder.toString());

	// for debug
	if (debug) {
		System.out.println("error code: start elem:" + builder.toString());
	}
	// end debug
}
 
Example #4
Source File: SessionPropertiesReadHandlerTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testDoneParsing() throws SAXException {
  Object prop = handler.getObject();
  assertThat( prop, is( nullValue() ) );

  XMLAttributesImpl attrs = new XMLAttributesImpl();
  attrs.addAttribute( new QName( null, "name", null, URI ), ATTR_TYPE, PROP_NAME );
  attrs.addAttribute( new QName( null, "value", null, URI ), ATTR_TYPE, PROP_VALUE );
  AttributesProxy fAttributesProxy = new AttributesProxy( attrs );

  XmlReadHandler childHandler = handler.getHandlerForChild( URI, "property", null );
  SessionPropertyReadHandler readHandler = (SessionPropertyReadHandler) childHandler;
  readHandler.init( rootXmlReadHandler, URI, TAG_NAME );
  readHandler.startParsing( fAttributesProxy );
  handler.doneParsing();
  prop = handler.getObject();

  assertThat( prop, is( instanceOf( Properties.class ) ) );
  assertThat( ( (Properties) prop ).getProperty( PROP_NAME ), is( equalTo( PROP_VALUE ) ) );
}
 
Example #5
Source File: ScriptableDataSourceReadHandlerTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testDoneParsingWithConfHandler() throws Exception {
  XMLAttributesImpl attrs = new XMLAttributesImpl();
  attrs.addAttribute( new QName( null, "language", null, URI ), ATTR_TYPE, LANG_VALUE );
  AttributesProxy fAttributesProxy = new AttributesProxy( attrs );

  handler.init( rootXmlReadHandler, URI, TAG_NAME );
  ConfigReadHandler confHandler = (ConfigReadHandler) handler.getHandlerForChild( URI, "config", null );
  confHandler.init( rootXmlReadHandler, URI, TAG_NAME );
  confHandler.startParsing( fAttributesProxy );

  handler.doneParsing();

  assertThat( handler.getDataFactory(), is( notNullValue() ) );
  assertThat( handler.getDataFactory(), is( instanceOf( ScriptableDataFactory.class ) ) );
  ScriptableDataFactory sdf = (ScriptableDataFactory) handler.getDataFactory();
  assertThat( sdf.getLanguage(), is( equalTo( LANG_VALUE ) ) );
  assertThat( sdf.getScript(), is( nullValue() ) );
  assertThat( sdf.getShutdownScript(), is( nullValue() ) );
}
 
Example #6
Source File: CorrectWriter.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
private String buildStartElementXmlStr(QName qname, XMLAttributesImpl attributes) {
	
	boolean format = attributes.getLength() > 3;
	
	StringBuilder builder = new StringBuilder();
	builder.append("<").append(qname.rawname);
	for (int i = 0; i < attributes.getLength(); i++) {
		if (format) {
			builder.append("\n\t");
		}
		builder.append(' ').append(attributes.getName(i)).append('=').append('\"').append(attributes.getValue(i))
				.append('\"');
	}
	builder.append('>');
	return builder.toString();
}
 
Example #7
Source File: CorrectWriter.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public void write(XMLString content) throws IOException, RepairableException {
	if (stack.fSize == 0) {
		return;
	}
	QName tq = new QName();
	stack.lastElement(tq);
	record.textAccept = schema.isTextAccept(tq, content);
	if (record.textAccept) {
		record.xmls.append(content);
	} else {
		record.textAccept = false;
		record.xmls.clear();
		record.tuset = false;
		throw new RepairableException(
				MessageFormat.format(Messages.getString("tmxeditor.tmxFileValidator.autofix.errorcode"), tq.rawname, ""));
	}
}
 
Example #8
Source File: ConfigReadHandlerTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testStartParsing() throws SAXException {
  XMLAttributesImpl attrs = new XMLAttributesImpl();
  attrs.addAttribute( new QName( null, "language", null, URI ), ATTR_TYPE, LANG_VALUE );
  attrs.addAttribute( new QName( null, "script", null, URI ), ATTR_TYPE, SCRIPT_VALUE );
  attrs.addAttribute( new QName( null, "shutdown-script", null, URI ), ATTR_TYPE, SHUTDOWN_SCRIPT_VALUE );
  AttributesProxy fAttributesProxy = new AttributesProxy( attrs );

  RootXmlReadHandler rootXmlReadHandler = mock( RootXmlReadHandler.class );

  ConfigReadHandler handler = new ConfigReadHandler();
  handler.init( rootXmlReadHandler, URI, "tag" );
  handler.startParsing( fAttributesProxy );

  assertThat( handler.getLanguage(), is( equalTo( LANG_VALUE ) ) );
  assertThat( handler.getScript(), is( equalTo( SCRIPT_VALUE ) ) );
  assertThat( handler.getShutdownScript(), is( equalTo( SHUTDOWN_SCRIPT_VALUE ) ) );
  assertThat( handler.getObject(), is( nullValue() ) );
}
 
Example #9
Source File: CMXSDElementDeclaration.java    From lemminx with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Returns list of element (QName) of child elements of the given parent element
 * upon the given offset
 * 
 * @param parentElement the parent element
 * @param offset        the offset where child element must be belong to
 * @return list of element (QName) of child elements of the given parent element
 *         upon the given offset
 */
private static List<QName> toQNames(DOMElement parentElement, int offset) {
	if (parentElement == null || !parentElement.hasChildNodes()) {
		return Collections.emptyList();
	}
	List<QName> qNames = new ArrayList<>();
	NodeList children = parentElement.getChildNodes();
	for (int i = 0; i < children.getLength(); i++) {
		Node child = children.item(i);
		if (child.getNodeType() == Node.ELEMENT_NODE) {
			// child node is an element
			DOMElement element = (DOMElement) child;
			if (element.getEnd() > offset) {
				// child element is after the given offset, stop the computing
				break;
			}
			if (!element.isClosed()) {
				// Element is not closed, ignore it
				continue;
			}
			qNames.add(createQName(element));
		}
	}
	return qNames;
}
 
Example #10
Source File: FormulaHeaderReadHandlerTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test( expected = ParseException.class )
public void testStartParsingWithoutFormula() throws SAXException {
  XMLAttributesImpl attrs = new XMLAttributesImpl();
  attrs.addAttribute( new QName( null, "name", null, URI ), ATTR_TYPE, NAME_VALUE );
  attrs.addAttribute( new QName( null, "formula", null, URI ), ATTR_TYPE, null );
  AttributesProxy fAttributesProxy = new AttributesProxy( attrs );

  handler.startParsing( fAttributesProxy );
}
 
Example #11
Source File: TmxScanner.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/** Default constructor. */
public ElementStack() {
	fElements = new QName[10];
	for (int i = 0; i < fElements.length; i++) {
		fElements[i] = new QName();
	}
}
 
Example #12
Source File: FormulaHeaderReadHandlerTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test( expected = ParseException.class )
public void testStartParsingWithoutName() throws SAXException {
  XMLAttributesImpl attrs = new XMLAttributesImpl();
  attrs.addAttribute( new QName( null, "name", null, URI ), ATTR_TYPE, null );
  attrs.addAttribute( new QName( null, "formula", null, URI ), ATTR_TYPE, FORMULA_VALUE );
  AttributesProxy fAttributesProxy = new AttributesProxy( attrs );

  handler.startParsing( fAttributesProxy );
}
 
Example #13
Source File: FormulaHeaderReadHandlerTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testStartParsing() throws SAXException {
  XMLAttributesImpl attrs = new XMLAttributesImpl();
  attrs.addAttribute( new QName( null, "name", null, URI ), ATTR_TYPE, NAME_VALUE );
  attrs.addAttribute( new QName( null, "formula", null, URI ), ATTR_TYPE, FORMULA_VALUE );
  AttributesProxy fAttributesProxy = new AttributesProxy( attrs );

  handler.startParsing( fAttributesProxy );

  Object result = handler.getObject();
  assertThat( result, is( notNullValue() ) );
  assertThat( result, is( CoreMatchers.instanceOf( FormulaHeader.class ) ) );
  FormulaHeader formulaHeader = (FormulaHeader) result;
  assertThat( formulaHeader.getName(), is( equalTo( NAME_VALUE ) ) );
}
 
Example #14
Source File: MailDefinitionReadHandlerTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testParsingBodyReport() throws Exception {
  XmlReadHandler childHandler = handler.getHandlerForChild( URI, "body-report", null );
  assertThat( childHandler, is( notNullValue() ) );
  assertThat( childHandler, is( instanceOf( ReportReadHandler.class ) ) );

  XMLAttributesImpl attrs = new XMLAttributesImpl();
  attrs.addAttribute( new QName( null, "target-type", null, URI ), "string", "test-target" );
  attrs.addAttribute( new QName( null, "href", null, URI ), "string", "test-href" );
  AttributesProxy fAttributesProxy = new AttributesProxy( attrs );

  RootXmlReadHandler rootXmlReadHandler = mock( RootXmlReadHandler.class );
  ResourceManagerBackend backend = mock( ResourceManagerBackend.class );
  ResourceManager resourceManager = new ResourceManager( backend );
  ResourceKey key = new ResourceKey( "schema", "identifier", null );
  Resource resource = mock( Resource.class );
  MasterReport report = mock( MasterReport.class );
  doReturn( resourceManager ).when( rootXmlReadHandler ).getResourceManager();
  doReturn( key ).when( backend ).deriveKey( any( ResourceKey.class ), anyString(),
      anyMapOf( ParameterKey.class, Object.class ) );
  doReturn( resource ).when( backend ).create( any( ResourceManager.class ), any( ResourceBundleData.class ),
      any( ResourceKey.class ), any( Class[].class ) );
  doReturn( new ResourceKey[] {} ).when( resource ).getDependencies();
  doReturn( key ).when( resource ).getSource();
  doReturn( getClass() ).when( resource ).getTargetType();
  doReturn( report ).when( resource ).getResource();

  ReportReadHandler reportHandler = (ReportReadHandler) childHandler;
  reportHandler.init( rootXmlReadHandler, URI, "body-report" );
  reportHandler.startParsing( fAttributesProxy );

  handler.doneParsing();

  Object objDefn = handler.getObject();
  assertThat( objDefn, is( notNullValue() ) );
  assertThat( objDefn, is( instanceOf( MailDefinition.class ) ) );
  MailDefinition mailDefn = (MailDefinition) objDefn;
  assertThat( mailDefn.getBodyReport(), is( equalTo( report ) ) );
}
 
Example #15
Source File: MailDefinitionReadHandlerTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testParsingSession() throws SAXException {
  XmlReadHandler childHandler = handler.getHandlerForChild( URI, "session", null );
  assertThat( childHandler, is( notNullValue() ) );
  assertThat( childHandler, is( instanceOf( SessionPropertiesReadHandler.class ) ) );

  XMLAttributesImpl attrs = new XMLAttributesImpl();
  attrs.addAttribute( new QName( null, "name", null, URI ), "string", "test_name" );
  attrs.addAttribute( new QName( null, "value", null, URI ), "string", "test_value" );
  AttributesProxy fAttributesProxy = new AttributesProxy( attrs );

  SessionPropertiesReadHandler sessionHandler = (SessionPropertiesReadHandler) childHandler;
  sessionHandler.init( mock( RootXmlReadHandler.class ), URI, "tag" );
  SessionPropertyReadHandler readHandler =
      (SessionPropertyReadHandler) sessionHandler.getHandlerForChild( URI, "property", null );
  readHandler.init( mock( RootXmlReadHandler.class ), URI, "tag" );
  readHandler.startParsing( fAttributesProxy );
  sessionHandler.doneParsing();

  handler.doneParsing();

  Object objDefn = handler.getObject();
  assertThat( objDefn, is( notNullValue() ) );
  assertThat( objDefn, is( instanceOf( MailDefinition.class ) ) );
  MailDefinition mailDefn = (MailDefinition) objDefn;
  assertThat( mailDefn.getSessionProperties(), is( notNullValue() ) );
  assertThat( mailDefn.getSessionProperties().getProperty( "test_name" ), is( equalTo( "test_value" ) ) );
}
 
Example #16
Source File: StaticHeaderReadHandlerTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testParsing() throws SAXException {
  XMLAttributesImpl attrs = new XMLAttributesImpl();
  attrs.addAttribute( new QName( null, "name", null, URI ), ATTR_TYPE, PROP_NAME );
  attrs.addAttribute( new QName( null, "value", null, URI ), ATTR_TYPE, PROP_VALUE );
  AttributesProxy fAttributesProxy = new AttributesProxy( attrs );

  handler.startParsing( fAttributesProxy );

  Object result = handler.getObject();
  assertThat( result, is( CoreMatchers.instanceOf( StaticHeader.class ) ) );
  StaticHeader header = (StaticHeader) result;
  assertThat( header.getName(), is( equalTo( PROP_NAME ) ) );
  assertThat( header.getValue( null ), is( equalTo( PROP_VALUE ) ) );
}
 
Example #17
Source File: ScriptableDataSourceReadHandlerTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testDoneParsing() throws Exception {
  XMLAttributesImpl attrs = new XMLAttributesImpl();
  attrs.addAttribute( new QName( null, "language", null, URI ), ATTR_TYPE, LANG_VALUE );
  attrs.addAttribute( new QName( null, "script", null, URI ), ATTR_TYPE, SCRIPT_VALUE );
  attrs.addAttribute( new QName( null, "shutdown-script", null, URI ), ATTR_TYPE, SHUTDOWN_SCRIPT_VALUE );
  AttributesProxy fAttributesProxy = new AttributesProxy( attrs );

  handler.init( rootXmlReadHandler, URI, TAG_NAME );
  ConfigReadHandler confHandler = (ConfigReadHandler) handler.getHandlerForChild( URI, "config", null );
  confHandler.init( rootXmlReadHandler, URI, TAG_NAME );
  confHandler.startParsing( fAttributesProxy );
  PropertyReadHandler queryHandler = (PropertyReadHandler) handler.getHandlerForChild( URI, "query", null );
  queryHandler.init( rootXmlReadHandler, URI, TAG_NAME );
  XMLAttributesImpl queryAttrs = new XMLAttributesImpl();
  queryAttrs.addAttribute( new QName( null, "name", null, URI ), ATTR_TYPE, QUERY_NAME );
  AttributesProxy queryAttrsProxy = new AttributesProxy( queryAttrs );
  queryHandler.startElement( URI, TAG_NAME, queryAttrsProxy );
  char[] chars = new char[] { 'b' };
  queryHandler.characters( chars, 0, chars.length );
  queryHandler.endElement( URI, TAG_NAME );

  handler.doneParsing();

  assertThat( handler.getDataFactory(), is( notNullValue() ) );
  assertThat( handler.getDataFactory(), is( instanceOf( ScriptableDataFactory.class ) ) );
  ScriptableDataFactory sdf = (ScriptableDataFactory) handler.getDataFactory();
  assertThat( sdf.getLanguage(), is( equalTo( LANG_VALUE ) ) );
  assertThat( sdf.getScript(), is( equalTo( SCRIPT_VALUE ) ) );
  assertThat( sdf.getShutdownScript(), is( equalTo( SHUTDOWN_SCRIPT_VALUE ) ) );
  assertThat( sdf.getQuery( QUERY_NAME ), is( equalTo( "b" ) ) );
  assertThat( handler.getObject(), is( instanceOf( ScriptableDataFactory.class ) ) );
  assertThat( (ScriptableDataFactory) handler.getObject(), is( equalTo( sdf ) ) );
}
 
Example #18
Source File: TmxScanner.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Pushes an element on the stack.
 * <p>
 * <strong>Note:</strong> The QName values are copied into the stack. In other words, the caller does
 * <em>not</em> orphan the element to the stack. Also, the QName object returned is <em>not</em> orphaned to the
 * caller. It should be considered read-only.
 * @param element
 *            The element to push onto the stack.
 * @return Returns the actual QName object that stores the
 */
public QName pushElement(QName element) {
	if (fSize == fElements.length) {
		QName[] array = new QName[fElements.length * 2];
		System.arraycopy(fElements, 0, array, 0, fSize);
		fElements = array;
		for (int i = fSize; i < fElements.length; i++) {
			fElements[i] = new QName();
		}
	}
	fElements[fSize].setValues(element);
	return fElements[fSize++];
}
 
Example #19
Source File: ScriptFilter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void endElement( QName element, Augmentations augs ) throws XNIException {
    if (_activeScriptBlock == null) {
        super.endElement( element, augs );
    } else {
        try {
            final String scriptText = _activeScriptBlock.toString();
            String replacementText = getTranslatedScript( _scriptLanguage, scriptText );
            _configuration.pushInputSource( newInputSource( replacementText ) );
        } catch (IOException e) { // ignore
        } finally {
            _activeScriptBlock = null;
        }
    }
}
 
Example #20
Source File: ReportReadHandlerTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test( expected = ParseException.class )
public void testParsingIncorrectHref() throws Exception {
  XMLAttributesImpl attrs = new XMLAttributesImpl();
  attrs.addAttribute( new QName( null, "target-type", null, URI ), ATTR_TYPE, TARGET );
  attrs.addAttribute( new QName( null, "href", null, URI ), ATTR_TYPE, null );
  AttributesProxy fAttributesProxy = new AttributesProxy( attrs );

  handler.startParsing( fAttributesProxy );
}
 
Example #21
Source File: StaticHeaderReadHandlerTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test( expected = ParseException.class )
public void testParsingWithoutName() throws SAXException {
  XMLAttributesImpl attrs = new XMLAttributesImpl();
  attrs.addAttribute( new QName( null, "name", null, URI ), ATTR_TYPE, null );
  attrs.addAttribute( new QName( null, "value", null, URI ), ATTR_TYPE, PROP_VALUE );
  AttributesProxy fAttributesProxy = new AttributesProxy( attrs );

  handler.startParsing( fAttributesProxy );
}
 
Example #22
Source File: ElementStack.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/** Default constructor. */
public ElementStack() {
    fElements = new QName[10];
    for (int i = 0; i < fElements.length; i++) {
        fElements[i] = new QName();
    }
}
 
Example #23
Source File: CorrectWriter.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
private void checkRoot() throws IOException {
	checkDoctype();
	if (!record.root) {
		bw.append("<tmx version=\"1.4\">");
		stack.pushElement(new QName(null, "tmx", "tmx", null));
		record.changed = true;
		record.root = true;
	}
}
 
Example #24
Source File: CorrectWriter.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void writeEndElement(QName qname) throws IOException, RepairableException {
	
	if (stack.fSize == 0) {
		return;
	}
	
	if (record.body && !record.tuset) {
		return;
	}
	
	// 是否合法
	if (schema.isInvalidElement(qname)) {
		record.tuset = false;
		record.xmls.clear();
		return;
	}

	// 是否配对
	QName tq = new QName();
	stack.lastElement(tq);
	if (qname.rawname.equals(tq.rawname)) {
		// build XML string
		StringBuilder builder = new StringBuilder();
		builder.append("</").append(qname.rawname).append(">\n");
		record.xmls.append(builder.toString());
		stack.popElement(tq);
	} else {
		record.tuset = false;
		record.xmls.clear();
	}

	// ok flush this tu
	if (tq.rawname.equals("tu") && record.tuset) {
		record.countTu++;
		record.tuset = false;
		bw.write(record.xmls.ch, record.xmls.offset, record.xmls.length);
	}
}
 
Example #25
Source File: TmxSchema.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public boolean isElementAccept(QName qname, QName qname1) {
	
	if (isInvalidElement(qname1)) {
		return false;
	}

	if (qname.rawname.equals("prop") || qname.rawname.equals("note")) {
		return false;
	}
	if (qname1.rawname.equals("prop") || qname1.rawname.equals("note")) {
		int i = map.get(qname.rawname);
		return i == 12 || i == 23 || i == 24;
	}
	return map.get(qname.rawname) + 1 == map.get(qname1.rawname);
}
 
Example #26
Source File: TmxSchema.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public boolean isTextAccept(QName qname, XMLString content) {
	boolean spaces = true;
	for (int i = content.offset; i < content.offset + content.length; i++) {
		spaces = spaces &&  XMLChar.isSpace(content.ch[i]);
	}
	if (spaces) {
		return true;
	}
	return acceptText.containsSymbol(qname.rawname);
}
 
Example #27
Source File: OpenID4JavaDOMParser.java    From openid4java with Apache License 2.0 5 votes vote down vote up
public void ignoredStartElement(QName element, XMLAttributes attrs, Augmentations augs)
{
    if (element.rawname.equals("HEAD")
            && this.fCurrentNode instanceof HTMLHtmlElement)
    {
        this.ignoredHeadStartElement = true;
    }
}
 
Example #28
Source File: HtmlUnitNekoDOMBuilder.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void startElement(final QName element, final XMLAttributes attributes, final Augmentations augs)
    throws XNIException {
    // augs might change so we store only the interesting part
    lastTagWasSynthesized_ = isSynthesized(augs);
    super.startElement(element, attributes, augs);
}
 
Example #29
Source File: ScriptFilter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invoked for a start element. If the element is a <script>, overrides the normal behavior to begin collecting
 * the script text.
 */
public void startElement( QName element, XMLAttributes attrs, Augmentations augs ) throws XNIException {
    if (!isSupportedScript( element, attrs )) {
        super.startElement( element, attrs, augs );
    } else {
        _activeScriptBlock = new StringBuffer();
        _scriptLanguage = getScriptLanguage( attrs );
        String srcAttribute = attrs.getValue( "src" );
        if (srcAttribute != null) _activeScriptBlock.append( _scriptHandler.getIncludedScript( srcAttribute ) );
    }
}
 
Example #30
Source File: NekoHtmlDocumentHandler.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Called to signal an empty element. This simply synthesizes a
 * startElement followed by an endElement event.
 */
@Override
public void emptyElement(QName element, XMLAttributes attributes,
        Augmentations augs) throws XNIException {
  this.startElement(element, attributes, augs);
  this.endElement(element, augs, true);
}