Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to skip html tags within a file loaded by EMF(XML parser thinks the <br> tags are a feature and fails to load)
How to skip html tags within a file loaded by EMF [message #524110] Tue, 30 March 2010 18:47 Go to next message
Tamar Cohen is currently offline Tamar CohenFriend
Messages: 103
Registered: July 2009
Senior Member
Hello EMF world,

So I have tried umpteen solutions I've found online to no avail. My problem is that certain areas (within <description>) in files I am loading contain html tags. The XMLHandler tries to process the tag as a feature. Instead I want the entire block as a string, which would contain the html tags.

I am using an ExtendedMetaData in my ResourceFactoryImpl, and I have played around with various load options; I have modified this attribute to be an element and tried OPTION_ESCAPE_USING_CDATA.

I have also tried setting the processing kind to mixed.

Has anyone else solved this problem? What am I missing?

Thanks much.
Tamar

The stack trace is here:

Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'br' not found. (file:/bla/bla/bla.kml, 40, 6)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1776)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1023)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(AbstractSAXParser.java:533)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocume ntParser.emptyElement(AbstractXMLDocumentParser.java:220)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScanner Impl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFra gmentScannerImpl.java:1693)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java: 368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(X MLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(AbstractSAXParser.java:1242)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1494)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1282)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
Re: How to skip html tags within a file loaded by EMF [message #524142 is a reply to message #524110] Tue, 30 March 2010 22:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010707080309000601040005
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Tamar,

Comments below.


Tamar Cohen wrote:
> Hello EMF world,
>
> So I have tried umpteen solutions I've found online to no avail. My
> problem is that certain areas (within <description>) in files I am
> loading contain html tags. The XMLHandler tries to process the tag as
> a feature. Instead I want the entire block as a string, which would
> contain the html tags.
No, you can't just turn structured XML into a string value.
>
> I am using an ExtendedMetaData in my ResourceFactoryImpl, and I have
> played around with various load options; I have modified this
> attribute to be an element and tried OPTION_ESCAPE_USING_CDATA.
> I have also tried setting the processing kind to mixed.
>
> Has anyone else solved this problem? What am I missing?
If you expressed to the model as an XML Schema, you'd make use of
wildcards, e.g., xsd:any. You can learn about how EMF supports those here:
< http://www.theserverside.com/news/1364302/Binding-XML-to-Jav a>

http://www.theserverside.com/news/1364302/Binding-XML-to-Jav a

>
> Thanks much.
> Tamar
>
> The stack trace is here:
>
> Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
> 'br' not found. (file:/bla/bla/bla.kml, 40, 6)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH
> andler.java:1776)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML
> Handler.java:1023)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa
> ndler.java:1001)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa
> ndler.java:712)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
> .startElement(AbstractSAXParser.java:533)
> at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocume
> ntParser.emptyElement(AbstractXMLDocumentParser.java:220)
> at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScanner
> Impl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS
> cannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFra
> gmentScannerImpl.java:1693)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS
> cannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java: 368)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio
> n.parse(XML11Configuration.java:834)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio
> n.parse(XML11Configuration.java:764)
> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(X
> MLParser.java:148)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
> .parse(AbstractSAXParser.java:1242)
> at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.
> java:181)
> at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes
> ourceImpl.java:180)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour
> ceImpl.java:1494)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour
> ceImpl.java:1282)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo
> ad(ResourceSetImpl.java:255)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo
> adHelper(ResourceSetImpl.java:270)

--------------010707080309000601040005
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Tamar,<br>
<br>
Comments below.<br>
<br>
<br>
Tamar Cohen wrote:
<blockquote cite="mid:hoth0e$ime$1@build.eclipse.org" type="cite">Hello
EMF world,
<br>
<br>
So I have tried umpteen solutions I've found online to no avail.  My
problem is that certain areas (within &lt;description&gt;) in files I
am loading contain html tags.  The XMLHandler tries to process the tag
as a feature.  Instead I want the entire block as a string, which would
contain the html tags.
<br>
</blockquote>
No, you can't just turn structured XML into a string value.<br>
<blockquote cite="mid:hoth0e$ime$1@build.eclipse.org" type="cite"><br>
I am using an ExtendedMetaData in my ResourceFactoryImpl, and I have
played around with various load options;  I have modified this
attribute to be an element and tried OPTION_ESCAPE_USING_CDATA.  <br>
I have also tried setting the processing kind to mixed.
<br>
<br>
Has anyone else solved this problem? What am I missing?
<br>
</blockquote>
If you expressed to the model as an XML Schema, you'd make use of
wildcards, e.g., xsd:any.   You can learn about how EMF supports those
here:<a
href=" http://www.theserverside.com/news/1364302/Binding-XML-to-Jav a"><br>
</a>
<blockquote><a
href=" http://www.theserverside.com/news/1364302/Binding-XML-to-Jav a"> http://www.theserverside.com/news/1364302/Binding-XML-to-Jav a</a><br>
</blockquote>
<blockquote cite="mid:hoth0e$ime$1@build.eclipse.org" type="cite"><br>
Thanks much.
<br>
Tamar
<br>
<br>
The stack trace is here:
<br>
<br>
Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
'br' not found. (<a class="moz-txt-link-freetext" href="file:/bla/bla/bla.kml">file:/bla/bla/bla.kml</a>, 40, 6)
<br>
    at  org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH
andler.java:1776)
<br>
    at  org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML
Handler.java:1023)
<br>
    at  org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa
ndler.java:1001)
<br>
    at  org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa
ndler.java:712)
<br>
    at  com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
..startElement(AbstractSAXParser.java:533)
<br>
    at  com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocume
ntParser.emptyElement(AbstractXMLDocumentParser.java:220)
<br>
    at  com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScanner
Impl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
<br>
    at  com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS
cannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFra
gmentScannerImpl.java:1693)
<br>
    at  com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS
cannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java: 368)
<br>
    at  com.sun.org.apache.xerces.internal.parsers.XML11Configuratio
n.parse(XML11Configuration.java:834)
<br>
    at  com.sun.org.apache.xerces.internal.parsers.XML11Configuratio
n.parse(XML11Configuration.java:764)
<br>
    at  com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(X
MLParser.java:148)
<br>
    at  com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
..parse(AbstractSAXParser.java:1242)
<br>
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
<br>
    at  org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.
java:181)
<br>
    at  org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes
ourceImpl.java:180)
<br>
    at  org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour
ceImpl.java:1494)
<br>
    at  org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour
ceImpl.java:1282)
<br>
    at  org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo
ad(ResourceSetImpl.java:255)
<br>
    at  org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo
adHelper(ResourceSetImpl.java:270)
<br>
</blockquote>
</body>
</html>

--------------010707080309000601040005--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to skip html tags within a file loaded by EMF [message #524437 is a reply to message #524142] Wed, 31 March 2010 22:11 Go to previous message
Tamar Cohen is currently offline Tamar CohenFriend
Messages: 103
Registered: July 2009
Senior Member
Thank you yet again, Ed!

So you are absolutely correct, XML with arbitrary content in a node is not valid. I extended the schema to make a type that extended anyType for the description, after referencing this:

http://www.w3.org/TR/xmlschema-0/#any

I reloaded my genmodel, generated new code, and verified that it loaded.

Thanks again for your direction and hopefully this post will help some others.

Tamar
Previous Topic:Unknown Features
Next Topic:Same document reference question
Goto Forum:
  


Current Time: Thu Apr 25 11:52:27 GMT 2024

Powered by FUDForum. Page generated in 0.02876 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top