Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » How to associate custom XML schema with XML editor?
How to associate custom XML schema with XML editor? [message #230533] Tue, 21 April 2009 18:14 Go to next message
Dan Hoyt is currently offline Dan HoytFriend
Messages: 13
Registered: July 2009
Junior Member
I am trying to add content assist and validation to the "stock" XML editor
in a standalone product that repackages the Eclipse 3.3.2 platform and
adds our own plugins. I have:

A) extended org.eclipse.core.contenttype.contentTypes with my own
content-type specifying a base type of org.eclipse.core.runtime.xml and a
org.eclipse.core.runtime.content.XMLRootElementContentDescri ber:myRootElement
describer.

B) extended org.eclipse.wst.xml.core.catalogContributions with my own
catalogContribution pointing to my .xsd file.

However, I don't see 1) how to associate the editor with my .xsd for
content assist (I thought this was done automatically by B); or 2) how to
enable "Validate" on the context menu in the Navigator.

I saw in Nitin's EclipseCon presentation that "It’s common to define your
own contentType, say for a specialized form of XML, based on some specific
DTD, and then associate it with your editor," but I can't find any
documentation explaining exactly how to do this.

Any help or direction would be appreciated.

-Dan Hoyt
Senior Systems Architect, TSC
Re: How to associate custom XML schema with XML editor? [message #230549 is a reply to message #230533] Tue, 21 April 2009 21:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

Dan Hoyt wrote:
> I am trying to add content assist and validation to the "stock" XML
> editor in a standalone product that repackages the Eclipse 3.3.2
> platform and adds our own plugins. I have:
>
> A) extended org.eclipse.core.contenttype.contentTypes with my own
> content-type specifying a base type of org.eclipse.core.runtime.xml and
> a
> org.eclipse.core.runtime.content.XMLRootElementContentDescri ber:myRootElement
> describer.
>
> B) extended org.eclipse.wst.xml.core.catalogContributions with my own
> catalogContribution pointing to my .xsd file.
>
> However, I don't see 1) how to associate the editor with my .xsd for
> content assist (I thought this was done automatically by B); or 2) how
> to enable "Validate" on the context menu in the Navigator.
>
> I saw in Nitin's EclipseCon presentation that "It�s common to define
> your own contentType, say for a specialized form of XML, based on some
> specific DTD, and then associate it with your editor," but I can't find
> any documentation explaining exactly how to do this.
> Any help or direction would be appreciated.

Well, there are a couple of ways to do this. If you have a Namespace
for your XML, you can contribute your Schemas to the XML Catalog through
the xmlCatalog extension point. Take a look at the
org.eclipse.wst.xml.core plugin for some examples on how to use the
extension point.

You can also use a custom URI Resolver to let the editor know which
grammar to load. Again there example code in the
org.eclipse.wst.xsl.core plugin that shows how we use the custom
resolver to determine which XSLT 2.0 grammar to use based on the version
attribute of the XSLT being edited.

Dave
Re: How to associate custom XML schema with XML editor? [message #230644 is a reply to message #230549] Thu, 23 April 2009 20:12 Go to previous messageGo to next message
Dan Hoyt is currently offline Dan HoytFriend
Messages: 13
Registered: July 2009
Junior Member
David,

I've registered the .xsd in the XML Catalog, but all I get on Ctrl-Space
after a "<" in a new document created with the "New/XML" wizard based on
my registered XML schema is the status line error message:

"Content Assist not available at the current location"

What am I doing wrong?

Regards,
Dan
Re: How to associate custom XML schema with XML editor? [message #230651 is a reply to message #230644] Thu, 23 April 2009 20:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

It would help to see some sample XML, as well as how you setup the XML
Catalog entry for the XSD.

Also does your XSD have a targetNamespace?

Dave

Dan Hoyt wrote:
> David,
>
> I've registered the .xsd in the XML Catalog, but all I get on Ctrl-Space
> after a "<" in a new document created with the "New/XML" wizard based on
> my registered XML schema is the status line error message:
> "Content Assist not available at the current location"
>
> What am I doing wrong?
>
> Regards,
> Dan
>
Re: How to associate custom XML schema with XML editor? [message #230660 is a reply to message #230651] Thu, 23 April 2009 22:13 Go to previous messageGo to next message
Dan Hoyt is currently offline Dan HoytFriend
Messages: 13
Registered: July 2009
Junior Member
Sorry for the omission. I was really just trying to understand the
conceptual answer, but here's my specifics if it will help. Note that the
URL listed in the namespace will not currently resolve on the web, but my
understanding is that Eclipse uses the local copy first, so that shouldn't
be a problem, right?

What does work:
1) When I right-click an XML file, I get a new "My XML Editor" entry.
2) When I open an XML file that has a "myRoot" root element (*):
A) The default editor that opens has my "my-xml.gif" icon.
B) A custom view I developed recognizes that my custom content was
loaded.
3) My schema shows up in "Preferences...|Web and XML|XML Catalog" under
the "Plugin Specified Entries".

(*) For example:
<?xml version="1.0" encoding="UTF-8"?>
<myRoot>
</myRoot>

What does NOT work:
1) When I use the "New|Other...|XML|XML" Wizard and select "Create XML
file from an XML schema file" and select my schema from the Catalog, the
"Root element:" selection list is empty.
2) Content assist on a file opened as "My XML Editor" gives me the error:
"Content Assist not available at the current location"

Regards,
Dan

--------------------------

My plugin's plugin.xml has defined:

<extension
point="org.eclipse.core.contenttype.contentTypes">
<content-type
base-type="org.eclipse.core.runtime.xml"

describer=" org.eclipse.core.runtime.content.XMLRootElementContentDescri ber:myRoot "
file-extensions="xml"
id="com.mycomany.myproduct.myXML"
name="My XML"
priority="normal">
</content-type>
</extension>
<extension
point="org.eclipse.ui.editors">
<editor

class=" org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditor Part "

contributorClass=" org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditor ActionBarContributor "
icon="icons/my-xml.gif"
id="com.mycompany.myproduct.xml"
name="My XML Editor">
<contentTypeBinding
contentTypeId="com.mycomany.myproduct.myXML">
</contentTypeBinding>
</editor>
</extension>
<extension
point="org.eclipse.wst.xml.core.catalogContributions">
<catalogContribution>
<uri
name="http://www.mycompany.com/myproduct/2009/XMLSchema"
uri="schema/myXML.xsd">
</uri>
</catalogContribution>
</extension>

--------------------------

My schema/myXML.xsd looks like:

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.mycompany.com/myproduct/2009/XMLSchema"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.mycompany.com/myproduct/2009/XMLSchema">

<element name="myRoot">
<complexType>
<sequence>
<element name="myEntry1" type="tns:EntryType"
maxOccurs="unbounded" minOccurs="0" />
<element name="myEntry2" type="tns:EntryType"
maxOccurs="unbounded" minOccurs="0" />
...
</sequence>
</complexType>
</element>

<complexType name="EntryType">
<choice maxOccurs="unbounded" minOccurs="0">
<element name="data" type="tns:DoubleValueType" maxOccurs="1"
minOccurs="1" />
<element name="data" type="tns:IntegerValueType" maxOccurs="1"
minOccurs="1" />
</choice>
<attribute name="index" type="int" use="optional" />
<attribute name="size" type="int" use="optional" />
</complexType>

<complexType name="DoubleValueType">
<complexContent>
<extension base="tns:HexValueType">
<attribute name="value" type="double" use="required" />
<attribute name="type" use="optional">
<simpleType>
<restriction base="string">
<pattern value=" " />
</restriction>
</simpleType>
</attribute>
</extension>
</complexContent>
</complexType>

<complexType name="IntegerValueType">
<complexContent>
<extension base="tns:HexValueType">
<attribute name="value" type="int" use="required" />
<attribute name="type" use="required">
<simpleType>
<restriction base="string">
<pattern value="[iI]" />
</restriction>
</simpleType>
</attribute>
</extension>
</complexContent>
</complexType>

...

</schema>
Re: How to associate custom XML schema with XML editor? [message #230668 is a reply to message #230660] Thu, 23 April 2009 23:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

Content Assistance for your Editor probably needs to have a
StructuredSourceViewerConfiguration enabled for it. Here is an example
from the XSLT editor:

<extension point="org.eclipse.wst.sse.ui.editorConfiguration">
<sourceViewerConfiguration

class=" org.eclipse.wst.xsl.ui.internal.StructuredTextViewerConfigur ationXSL "
target="org.eclipse.wst.xml.core.xslsource">
</sourceViewerConfiguration>
</extension>

You'll want to setup the target for your particular content id. You
can use the same StructuredTextViewrConfigurationXML if all you want is
the base support as is provided by the XML editor. So in your case the
target id is: com.mycomany.myproduct.myXML

The question I have in regards to your Schema is, what happens if you
load up using the default XML editor. Do you get the content assistance
that you expect. Your Schema looks fine, and the way you are
contributing to it looks alright.

Dave


Dan Hoyt wrote:
> Sorry for the omission. I was really just trying to understand the
> conceptual answer, but here's my specifics if it will help. Note that
> the URL listed in the namespace will not currently resolve on the web,
> but my understanding is that Eclipse uses the local copy first, so that
> shouldn't be a problem, right?
>
> What does work:
> 1) When I right-click an XML file, I get a new "My XML Editor" entry.
> 2) When I open an XML file that has a "myRoot" root element (*):
> A) The default editor that opens has my "my-xml.gif" icon.
> B) A custom view I developed recognizes that my custom content was
> loaded.
> 3) My schema shows up in "Preferences...|Web and XML|XML Catalog" under
> the "Plugin Specified Entries".
>
> (*) For example:
> <?xml version="1.0" encoding="UTF-8"?>
> <myRoot>
> </myRoot>
>
> What does NOT work:
> 1) When I use the "New|Other...|XML|XML" Wizard and select "Create XML
> file from an XML schema file" and select my schema from the Catalog, the
> "Root element:" selection list is empty.
> 2) Content assist on a file opened as "My XML Editor" gives me the error:
> "Content Assist not available at the current location"
>
> Regards,
> Dan
>
> --------------------------
>
> My plugin's plugin.xml has defined:
>
> <extension
> point="org.eclipse.core.contenttype.contentTypes">
> <content-type
> base-type="org.eclipse.core.runtime.xml"
>
> describer=" org.eclipse.core.runtime.content.XMLRootElementContentDescri ber:myRoot "
>
> file-extensions="xml"
> id="com.mycomany.myproduct.myXML"
> name="My XML"
> priority="normal">
> </content-type>
> </extension>
> <extension
> point="org.eclipse.ui.editors">
> <editor
>
> class=" org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditor Part "
>
> contributorClass=" org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditor ActionBarContributor "
>
> icon="icons/my-xml.gif"
> id="com.mycompany.myproduct.xml"
> name="My XML Editor">
> <contentTypeBinding
> contentTypeId="com.mycomany.myproduct.myXML">
> </contentTypeBinding>
> </editor>
> </extension>
> <extension
> point="org.eclipse.wst.xml.core.catalogContributions">
> <catalogContribution>
> <uri
> name="http://www.mycompany.com/myproduct/2009/XMLSchema"
> uri="schema/myXML.xsd">
> </uri>
> </catalogContribution>
> </extension>
>
> --------------------------
>
> My schema/myXML.xsd looks like:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <schema targetNamespace="http://www.mycompany.com/myproduct/2009/XMLSchema"
> xmlns="http://www.w3.org/2001/XMLSchema"
> xmlns:tns="http://www.mycompany.com/myproduct/2009/XMLSchema">
>
> <element name="myRoot">
> <complexType>
> <sequence>
> <element name="myEntry1" type="tns:EntryType"
> maxOccurs="unbounded" minOccurs="0" />
> <element name="myEntry2" type="tns:EntryType"
> maxOccurs="unbounded" minOccurs="0" />
> ...
> </sequence>
> </complexType>
> </element>
>
> <complexType name="EntryType">
> <choice maxOccurs="unbounded" minOccurs="0">
> <element name="data" type="tns:DoubleValueType" maxOccurs="1"
> minOccurs="1" />
> <element name="data" type="tns:IntegerValueType" maxOccurs="1"
> minOccurs="1" />
> </choice>
> <attribute name="index" type="int" use="optional" />
> <attribute name="size" type="int" use="optional" />
> </complexType>
>
> <complexType name="DoubleValueType">
> <complexContent>
> <extension base="tns:HexValueType">
> <attribute name="value" type="double" use="required" />
> <attribute name="type" use="optional">
> <simpleType>
> <restriction base="string">
> <pattern value=" " />
> </restriction>
> </simpleType>
> </attribute>
> </extension>
> </complexContent>
> </complexType>
>
> <complexType name="IntegerValueType">
> <complexContent>
> <extension base="tns:HexValueType">
> <attribute name="value" type="int" use="required" />
> <attribute name="type" use="required">
> <simpleType>
> <restriction base="string">
> <pattern value="[iI]" />
> </restriction>
> </simpleType>
> </attribute>
> </extension>
> </complexContent>
> </complexType>
>
> ...
>
> </schema>
>
>
Re: How to associate custom XML schema with XML editor? [message #230804 is a reply to message #230668] Mon, 27 April 2009 22:54 Go to previous messageGo to next message
Dan Hoyt is currently offline Dan HoytFriend
Messages: 13
Registered: July 2009
Junior Member
David,

I tried configuring the sourceViewerConfiguration, but it didn't appear to
have any effect, even with a namespace attribute on the root element in my
XML file:

<?xml version="1.0" encoding="UTF-8"?>
<myRoot xmlns="http://www.mycompany.com/myproduct/2009/XMLSchema">
...
</myRoot>

This is what I added this to the plugin.xml:

<extension point="org.eclipse.wst.sse.ui.editorConfiguration">
<sourceViewerConfiguration

class="org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML "
target="com.mycompany.myproduct.myXML">
</sourceViewerConfiguration>
</extension>

Also, I still don't understand why "Create XML file from an XML schema
file" fails to find the root element.

Regards,
Dan


David Carver wrote:

> Content Assistance for your Editor probably needs to have a
> StructuredSourceViewerConfiguration enabled for it. Here is an example
> from the XSLT editor:

> <extension point="org.eclipse.wst.sse.ui.editorConfiguration">
> <sourceViewerConfiguration

> class=" org.eclipse.wst.xsl.ui.internal.StructuredTextViewerConfigur ationXSL "
> target="org.eclipse.wst.xml.core.xslsource">
> </sourceViewerConfiguration>
> </extension>

> You'll want to setup the target for your particular content id. You
> can use the same StructuredTextViewrConfigurationXML if all you want is
> the base support as is provided by the XML editor. So in your case the
> target id is: com.mycomany.myproduct.myXML

> The question I have in regards to your Schema is, what happens if you
> load up using the default XML editor. Do you get the content assistance
> that you expect. Your Schema looks fine, and the way you are
> contributing to it looks alright.

> Dave


> Dan Hoyt wrote:
>> Sorry for the omission. I was really just trying to understand the
>> conceptual answer, but here's my specifics if it will help. Note that
>> the URL listed in the namespace will not currently resolve on the web,
>> but my understanding is that Eclipse uses the local copy first, so that
>> shouldn't be a problem, right?
>>
>> What does work:
>> 1) When I right-click an XML file, I get a new "My XML Editor" entry.
>> 2) When I open an XML file that has a "myRoot" root element (*):
>> A) The default editor that opens has my "my-xml.gif" icon.
>> B) A custom view I developed recognizes that my custom content was
>> loaded.
>> 3) My schema shows up in "Preferences...|Web and XML|XML Catalog" under
>> the "Plugin Specified Entries".
>>
>> (*) For example:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <myRoot>
>> </myRoot>
>>
>> What does NOT work:
>> 1) When I use the "New|Other...|XML|XML" Wizard and select "Create XML
>> file from an XML schema file" and select my schema from the Catalog, the
>> "Root element:" selection list is empty.
>> 2) Content assist on a file opened as "My XML Editor" gives me the error:
>> "Content Assist not available at the current location"
>>
>> Regards,
>> Dan
>>
>> --------------------------
>>
>> My plugin's plugin.xml has defined:
>>
>> <extension
>> point="org.eclipse.core.contenttype.contentTypes">
>> <content-type
>> base-type="org.eclipse.core.runtime.xml"
>>
>>
describer=" org.eclipse.core.runtime.content.XMLRootElementContentDescri ber:myRoot "
>>
>> file-extensions="xml"
>> id="com.mycompany.myproduct.myXML"
>> name="My XML"
>> priority="normal">
>> </content-type>
>> </extension>
>> <extension
>> point="org.eclipse.ui.editors">
>> <editor
>>
>> class=" org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditor Part "
>>
>>
contributorClass=" org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditor ActionBarContributor "
>>
>> icon="icons/my-xml.gif"
>> id="com.mycompany.myproduct.xml"
>> name="My XML Editor">
>> <contentTypeBinding
>> contentTypeId="com.mycompany.myproduct.myXML">
>> </contentTypeBinding>
>> </editor>
>> </extension>
>> <extension
>> point="org.eclipse.wst.xml.core.catalogContributions">
>> <catalogContribution>
>> <uri
>> name="http://www.mycompany.com/myproduct/2009/XMLSchema"
>> uri="schema/myXML.xsd">
>> </uri>
>> </catalogContribution>
>> </extension>
>>
>> --------------------------
>>
>> My schema/myXML.xsd looks like:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <schema targetNamespace="http://www.mycompany.com/myproduct/2009/XMLSchema"
>> xmlns="http://www.w3.org/2001/XMLSchema"
>> xmlns:tns="http://www.mycompany.com/myproduct/2009/XMLSchema">
>>
>> <element name="myRoot">
>> <complexType>
>> <sequence>
>> <element name="myEntry1" type="tns:EntryType"
>> maxOccurs="unbounded" minOccurs="0" />
>> <element name="myEntry2" type="tns:EntryType"
>> maxOccurs="unbounded" minOccurs="0" />
>> ...
>> </sequence>
>> </complexType>
>> </element>
>>
>> <complexType name="EntryType">
>> <choice maxOccurs="unbounded" minOccurs="0">
>> <element name="data" type="tns:DoubleValueType" maxOccurs="1"
>> minOccurs="1" />
>> <element name="data" type="tns:IntegerValueType" maxOccurs="1"
>> minOccurs="1" />
>> </choice>
>> <attribute name="index" type="int" use="optional" />
>> <attribute name="size" type="int" use="optional" />
>> </complexType>
>>
>> <complexType name="DoubleValueType">
>> <complexContent>
>> <extension base="tns:HexValueType">
>> <attribute name="value" type="double" use="required" />
>> <attribute name="type" use="optional">
>> <simpleType>
>> <restriction base="string">
>> <pattern value=" " />
>> </restriction>
>> </simpleType>
>> </attribute>
>> </extension>
>> </complexContent>
>> </complexType>
>>
>> <complexType name="IntegerValueType">
>> <complexContent>
>> <extension base="tns:HexValueType">
>> <attribute name="value" type="int" use="required" />
>> <attribute name="type" use="required">
>> <simpleType>
>> <restriction base="string">
>> <pattern value="[iI]" />
>> </restriction>
>> </simpleType>
>> </attribute>
>> </extension>
>> </complexContent>
>> </complexType>
>>
>> ...
>>
>> </schema>
>>
>>
Re: How to associate custom XML schema with XML editor? [message #230810 is a reply to message #230804] Tue, 28 April 2009 01:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

Does it work with the WTP XML editor.

1. Does it load your grammar.
2. Is content assistance available for your element.

This will help to determine what is happening.

Dave

Dan Hoyt wrote:
> David,
>
> I tried configuring the sourceViewerConfiguration, but it didn't appear
> to have any effect, even with a namespace attribute on the root element
> in my XML file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <myRoot xmlns="http://www.mycompany.com/myproduct/2009/XMLSchema">
> ..
> </myRoot>
>
> This is what I added this to the plugin.xml:
>
> <extension point="org.eclipse.wst.sse.ui.editorConfiguration">
> <sourceViewerConfiguration
>
> class="org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML "
> target="com.mycompany.myproduct.myXML">
> </sourceViewerConfiguration>
> </extension>
>
> Also, I still don't understand why "Create XML file from an XML schema
> file" fails to find the root element.
>
> Regards,
> Dan
>
>
> David Carver wrote:
>
>> Content Assistance for your Editor probably needs to have a
>> StructuredSourceViewerConfiguration enabled for it. Here is an
>> example from the XSLT editor:
>
>> <extension point="org.eclipse.wst.sse.ui.editorConfiguration">
>> <sourceViewerConfiguration
>
>> class=" org.eclipse.wst.xsl.ui.internal.StructuredTextViewerConfigur ationXSL "
>>
>> target="org.eclipse.wst.xml.core.xslsource">
>> </sourceViewerConfiguration>
>> </extension>
>
>> You'll want to setup the target for your particular content id. You
>> can use the same StructuredTextViewrConfigurationXML if all you want
>> is the base support as is provided by the XML editor. So in your case
>> the target id is: com.mycomany.myproduct.myXML
>
>> The question I have in regards to your Schema is, what happens if you
>> load up using the default XML editor. Do you get the content
>> assistance that you expect. Your Schema looks fine, and the way you
>> are contributing to it looks alright.
>
>> Dave
>
>
>> Dan Hoyt wrote:
>>> Sorry for the omission. I was really just trying to understand the
>>> conceptual answer, but here's my specifics if it will help. Note
>>> that the URL listed in the namespace will not currently resolve on
>>> the web, but my understanding is that Eclipse uses the local copy
>>> first, so that shouldn't be a problem, right?
>>>
>>> What does work:
>>> 1) When I right-click an XML file, I get a new "My XML Editor" entry.
>>> 2) When I open an XML file that has a "myRoot" root element (*):
>>> A) The default editor that opens has my "my-xml.gif" icon.
>>> B) A custom view I developed recognizes that my custom content was
>>> loaded.
>>> 3) My schema shows up in "Preferences...|Web and XML|XML Catalog"
>>> under the "Plugin Specified Entries".
>>>
>>> (*) For example:
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <myRoot>
>>> </myRoot>
>>>
>>> What does NOT work:
>>> 1) When I use the "New|Other...|XML|XML" Wizard and select "Create
>>> XML file from an XML schema file" and select my schema from the
>>> Catalog, the "Root element:" selection list is empty.
>>> 2) Content assist on a file opened as "My XML Editor" gives me the
>>> error:
>>> "Content Assist not available at the current location"
>>>
>>> Regards,
>>> Dan
>>>
>>> --------------------------
>>>
>>> My plugin's plugin.xml has defined:
>>>
>>> <extension
>>> point="org.eclipse.core.contenttype.contentTypes">
>>> <content-type
>>> base-type="org.eclipse.core.runtime.xml"
>>>
> describer=" org.eclipse.core.runtime.content.XMLRootElementContentDescri ber:myRoot "
>
>>>
>>> file-extensions="xml"
>>> id="com.mycompany.myproduct.myXML"
>>> name="My XML"
>>> priority="normal">
>>> </content-type>
>>> </extension>
>>> <extension
>>> point="org.eclipse.ui.editors">
>>> <editor
>>>
>>> class=" org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditor Part "
>>>
> contributorClass=" org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditor ActionBarContributor "
>
>>>
>>> icon="icons/my-xml.gif"
>>> id="com.mycompany.myproduct.xml"
>>> name="My XML Editor">
>>> <contentTypeBinding
>>> contentTypeId="com.mycompany.myproduct.myXML">
>>> </contentTypeBinding>
>>> </editor>
>>> </extension>
>>> <extension
>>> point="org.eclipse.wst.xml.core.catalogContributions">
>>> <catalogContribution>
>>> <uri
>>> name="http://www.mycompany.com/myproduct/2009/XMLSchema"
>>> uri="schema/myXML.xsd">
>>> </uri>
>>> </catalogContribution>
>>> </extension>
>>>
>>> --------------------------
>>>
>>> My schema/myXML.xsd looks like:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <schema
>>> targetNamespace="http://www.mycompany.com/myproduct/2009/XMLSchema"
>>> xmlns="http://www.w3.org/2001/XMLSchema"
>>> xmlns:tns="http://www.mycompany.com/myproduct/2009/XMLSchema">
>>>
>>> <element name="myRoot">
>>> <complexType>
>>> <sequence>
>>> <element name="myEntry1" type="tns:EntryType"
>>> maxOccurs="unbounded" minOccurs="0" />
>>> <element name="myEntry2" type="tns:EntryType"
>>> maxOccurs="unbounded" minOccurs="0" />
>>> ...
>>> </sequence>
>>> </complexType>
>>> </element>
>>>
>>> <complexType name="EntryType">
>>> <choice maxOccurs="unbounded" minOccurs="0">
>>> <element name="data" type="tns:DoubleValueType" maxOccurs="1"
>>> minOccurs="1" />
>>> <element name="data" type="tns:IntegerValueType" maxOccurs="1"
>>> minOccurs="1" />
>>> </choice>
>>> <attribute name="index" type="int" use="optional" />
>>> <attribute name="size" type="int" use="optional" />
>>> </complexType>
>>>
>>> <complexType name="DoubleValueType">
>>> <complexContent>
>>> <extension base="tns:HexValueType">
>>> <attribute name="value" type="double" use="required" />
>>> <attribute name="type" use="optional">
>>> <simpleType>
>>> <restriction base="string">
>>> <pattern value=" " />
>>> </restriction>
>>> </simpleType>
>>> </attribute>
>>> </extension>
>>> </complexContent>
>>> </complexType>
>>>
>>> <complexType name="IntegerValueType">
>>> <complexContent>
>>> <extension base="tns:HexValueType">
>>> <attribute name="value" type="int" use="required" />
>>> <attribute name="type" use="required">
>>> <simpleType>
>>> <restriction base="string">
>>> <pattern value="[iI]" />
>>> </restriction>
>>> </simpleType>
>>> </attribute>
>>> </extension>
>>> </complexContent>
>>> </complexType>
>>>
>>> ...
>>>
>>> </schema>
>>>
>>>
>
>
Re: How to associate custom XML schema with XML editor? [message #230818 is a reply to message #230804] Tue, 28 April 2009 01:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

Dan Hoyt wrote:

> Also, I still don't understand why "Create XML file from an XML schema
> file" fails to find the root element.

Dan, make sure your Schema is valid. I added it manually to the XML
Catalog through a user contribution, and it works, if the schema is
valid. The one you provided in your example isn't valid as is. I had
to clean up the errors. . Once the errors were corrected, the myRoot
element shows as an option during the XML generation. I selected the
item from the xmlCatalog.

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.mycompany.com/myproduct/2009/XMLSchema"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.mycompany.com/myproduct/2009/XMLSchema">

<element name="myRoot">
<complexType>
<sequence>
<element name="myEntry1" type="tns:EntryType"
maxOccurs="unbounded" minOccurs="0" />
<element name="myEntry2" type="tns:EntryType"
maxOccurs="unbounded" minOccurs="0" />
</sequence>
</complexType>
</element>

<complexType name="EntryType">
<choice maxOccurs="unbounded" minOccurs="0">
<element name="data1" type="tns:DoubleValueType" maxOccurs="1"
minOccurs="1" />
<element name="data2" type="tns:IntegerValueType" maxOccurs="1"
minOccurs="1" />
</choice>
<attribute name="index" type="int" use="optional" />
<attribute name="size" type="int" use="optional" />
</complexType>

<complexType name="DoubleValueType">
<complexContent>
<extension base="tns:HexValueType">
<attribute name="value" type="double" use="required" />
<attribute name="type" use="optional">
<simpleType>
<restriction base="string">
<pattern value=" " />
</restriction>
</simpleType>
</attribute>
</extension>
</complexContent>
</complexType>

<complexType name="IntegerValueType">
<complexContent>
<extension base="tns:HexValueType">
<attribute name="value" type="int" use="required" />
<attribute name="type" use="required">
<simpleType>
<restriction base="string">
<pattern value="[iI]" />
</restriction>
</simpleType>
</attribute>
</extension>
</complexContent>
</complexType>
<complexType name="HexValueType"/>
</schema>
Re: How to associate custom XML schema with XML editor? [message #1786456 is a reply to message #230818] Thu, 03 May 2018 15:30 Go to previous message
Eclipse UserFriend
Although this is many years later, I wanted to point out that WTP XML offers a hook to provide schema locations for a file via the org.eclipse.wst.xml.core.externalSchemaLocations extension point. The provider can provide either an xsi:schemaLocation or xsi:noNamespaceSchemaLocation.
Previous Topic:Publishing error in tomcat v8.5 while configuring Tomcat
Next Topic:JE22 project layout ...
Goto Forum:
  


Current Time: Thu Apr 18 22:49:56 GMT 2024

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

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

Back to the top