<appinfo> tag not generated during model export to XSD [message #1706581] |
Thu, 27 August 2015 15:56  |
Eclipse User |
|
|
|
Hi,
I am new to EMF and an attempting to define a domin model using EMF. I have defined an eAttribute and documented it with an eAnnotation. I want to be able to generate a XSD that has both a documentation and appinfo tag like this:
<xsd:annotation>
<xsd:documentation> attribute information</xsd:documentation>
<xsd:appinfo> application specific info for attribute <xsd:appinfo>
</xsd:annotation>
The following shows the excerpt from the ecore file the way I would expect the eAnnotation to be defined in EMF:
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="attribute information"/>
<details key="appinfo" value="application specific info for attribute"/>
</eAnnotations>
The problem is, when I generate the XSD from the ecore file, I do not see the appinfo information. Only the documentation tag is generated (e.g.
<xsd:annotation>
<xsd:documentation> attribute information</xsd:documentation>
</xsd:annotation>
The book "EMF: Eclipse Modeling Framework, Second Edition" says
Quote:
"An xsd:appinfo element in a schema component's xsd:annotation maps to an EAnnotation whose source is the same as the source attribute of the xsd:appinfo, or null if none is provided. The EAnnotation's details map contains a single entry:
•key = "appinfo", value = the contents of the xsd:appinfo element"
The book implies that it is a no-brainer to create an appinfo tag in the XSD. I have tried to define the appinfo annotation in almost every combination but with no luck. Is this a bug or am is missing something? Thanks in advance for the help.
Regards,
--Jim
|
|
|
Re: <appinfo> tag not generated during model export to XSD [message #1706720 is a reply to message #1706581] |
Sat, 29 August 2015 03:11   |
Eclipse User |
|
|
|
Jim,
For the purpose of converting to XML Schema, these two annotations
sources are ignored:
protected boolean isIgnoredAnnotationSource(String sourceURI)
{
return
EcorePackage.eNS_URI.equals(sourceURI) ||
ExtendedMetaData.ANNOTATION_URI.equals(sourceURI) ||
GEN_MODEL_PACKAGE_NS_URI.equals(sourceURI);
}
Otherwise the behavior is quite subtle. If the value has no newlines
it's coverted to a non-schema namespace attribute:
<eAnnotations source="foo">
<details key="appinfo" value="Foo"/>
</eAnnotations>
->
<xsd:schema xmlns:foo="foo" foo:appinfo="Foo" ...
If it contains a newline, it's converted to an appinfo.
<eAnnotations source="bar">
<details key="appinfo" value="
Bar"/>
</eAnnotations>
->
<xsd:annotation>
<xsd:appinfo ecore:key="appinfo" source="bar">
Bar</xsd:appinfo>
On 28/08/2015 3:02 PM, Jim Boone wrote:
> Hi,
>
> I am new to EMF and an attempting to define a domin model using EMF.
> I have defined an eAttribute and documented it with an eAnnotation. I
> want to be able to generate a XSD that has both a documentation and
> appinfo tag like this:
>
>
> <xsd:annotation>
> <xsd:documentation> attribute information</xsd:documentation>
> <xsd:appinfo> application specific info for attribute <xsd:appinfo>
> </xsd:annotation>
>
>
> The following shows the excerpt from the ecore file the way I would
> expect the eAnnotation to be defined in EMF:
>
>
> <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
> <details key="documentation" value="attribute information"/>
> <details key="appinfo" value="application specific info for
> attribute"/>
> </eAnnotations>
>
>
> The problem is, when I generate the XSD from the ecore file, I do not
> see the appinfo information. Only the documentation tag is generated
> (e.g.
> <xsd:annotation>
> <xsd:documentation> attribute information</xsd:documentation>
> </xsd:annotation>
>
>
> The book "EMF: Eclipse Modeling Framework, Second Edition" says Quote:
>> "An xsd:appinfo element in a schema component's xsd:annotation maps
>> to an EAnnotation whose source is the same as the source attribute of
>> the xsd:appinfo, or null if none is provided. The EAnnotation's
>> details map contains a single entry:
>>
>> •key = "appinfo", value = the contents of the xsd:appinfo element"
>
>
> The book implies that it is a no-brainer to create an appinfo tag in
> the XSD. I have tried to define the appinfo annotation in almost every
> combination but with no luck. Is this a bug or am is missing
> something? Thanks in advance for the help.
>
> Regards,
> --Jim
>
>
|
|
|
|
Re: <appinfo> tag not generated during model export to XSD [message #1707048 is a reply to message #1707028] |
Tue, 01 September 2015 16:16  |
Eclipse User |
|
|
|
I considered the options and decided that the XSLT transform option was the best one since I was already running my schemas through transforms as part of the Maven build process. I looked at the source and it would have been a trivial change but the following xslt file is less hassle. Thanks for the prompt feedback!
<xsl:stylesheet version="3.0" xmlns:xsl="htt://www.w3.org/1999/XSL/Transform" xmlns:xs="htt://www.w3.org/2001/XMLSchema" xmlns:fn="htt://www.w3.org/2005/xpath-functions" xmlns:xsd="htt://www.w3.org/2001/XMLSchema">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xsd:appinfo">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
|
|
|
Powered by
FUDForum. Page generated in 0.03751 seconds