Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » use custom xsd with the StructuredTextEditor
use custom xsd with the StructuredTextEditor [message #209886] Fri, 07 March 2008 13:11 Go to next message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

Hi,

I need the content assist feature for some of my xsd, how can I tell the
StructuredTextEditor to parse my xsd's files

Thanks

Alexandre
Re: use custom xsd with the StructuredTextEditor [message #209897 is a reply to message #209886] Fri, 07 March 2008 13:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Alexandre,

If I understand the posts I've read here, I think you'd register the
namespace of the schema in the XML catalog...


Alexandre Jaquet wrote:
> Hi,
>
> I need the content assist feature for some of my xsd, how can I tell
> the StructuredTextEditor to parse my xsd's files
>
> Thanks
>
> Alexandre
Re: use custom xsd with the StructuredTextEditor [message #209904 is a reply to message #209897] Fri, 07 March 2008 13:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

Where / How can I get the xml catalog ?,

rigth now I've written an editor that extends the StructuredTextEditor
-I set the source viewer configuration to a custom one
-my source viewer configuration class extends
StructuredTextViewerConfigurationXML
-I've created a scanner for my editor
-I've created a completion processor

With the normal TextEditor you only needs to define what are the
completion propals

What I do I missed for the StructuredTextEditor

Thanks

Alexandre

Ed Merks a écrit :
> Alexandre,
>
> If I understand the posts I've read here, I think you'd register the
> namespace of the schema in the XML catalog...
>
>
> Alexandre Jaquet wrote:
>> Hi,
>>
>> I need the content assist feature for some of my xsd, how can I tell
>> the StructuredTextEditor to parse my xsd's files
>>
>> Thanks
>>
>> Alexandre
Re: use custom xsd with the StructuredTextEditor [message #209912 is a reply to message #209904] Fri, 07 March 2008 13:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

I found where the xml catalog is and tryed to import my xsd. The
completion doesn't work.
Re: use custom xsd with the StructuredTextEditor [message #209934 is a reply to message #209912] Fri, 07 March 2008 15:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

The completion work only if I add the doctype declaration at the begin
of my file (my file represent a portion of code and cannot contain xml
declaration and a doctype)

Is it possible to hide these declaration and make the completion still
working.

To make it work I've to declare

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xgui:module PUBLIC "-TOTO-" "unknown.dtd">

Any idea ?
Re: use custom xsd with the StructuredTextEditor [message #209942 is a reply to message #209897] Fri, 07 March 2008 15:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

There are a couple of ways to do this, depending on how your XSD is setup.

If it is namespace aware, then as ED said, you can register it in the
XML Catalog by namespace, and have it load the appropriate XSD based on
the namespace in the xml. This will require you specifying at the
minimum a xmlns="" attribute with the appropriate namespace filled in,
in the XML instance.

The other option is to use the xsi:schemaLocation="" attribute to
specify where the schema can be found locally.

http://xerces.apache.org/xerces-j/schema.html

Dave

Ed Merks wrote:
> Alexandre,
>
> If I understand the posts I've read here, I think you'd register the
> namespace of the schema in the XML catalog...
>
>
> Alexandre Jaquet wrote:
>> Hi,
>>
>> I need the content assist feature for some of my xsd, how can I tell
>> the StructuredTextEditor to parse my xsd's files
>>
>> Thanks
>>
>> Alexandre
Re: use custom xsd with the StructuredTextEditor [message #209950 is a reply to message #209934] Fri, 07 March 2008 15:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

Alexandre:

Take a look a the following tutorial on the XML Catalog. You need to
make sure you specify it correctly. Again if you have an XSD that is
tied to a namespace, you can use the xmlns="" attribute to set the
default namespace, and the eclipse xml editor should pickup the grammar
from there by looking in the xml catalog.

http://www.eclipse.org/webtools/community/tutorials/XMLCatal og/XMLCatalogTutorial.html


Alexandre Jaquet wrote:
> The completion work only if I add the doctype declaration at the begin
> of my file (my file represent a portion of code and cannot contain xml
> declaration and a doctype)
>
> Is it possible to hide these declaration and make the completion still
> working.
>
> To make it work I've to declare
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE xgui:module PUBLIC "-TOTO-" "unknown.dtd">
>
> Any idea ?
Re: use custom xsd with the StructuredTextEditor [message #209958 is a reply to message #209942] Fri, 07 March 2008 15:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

Hi David,

There is no way to avoid the declaration in the xml file ? Like doing
the content assist for a normal TextEditor ?

http://wiki.eclipse.org/FAQ_How_do_I_add_Content_Assist_to_m y_editor%3F
code sample
http://www.google.com/codesearch?hl=en&q=show:7vc44WIFVK E:bhXBMftasZk:yC8Jo0ZNTP4&sa=N&ct=rd&cs_p=http:/ /devresource.hp.com/drc/technical_white_papers/eclipeditor/M yEditor3.zip&cs_f=MyEditor3/src/MyEditor/editors/MySourc eViewerConfig.java&start=1

Regards

Alexandre
Re: use custom xsd with the StructuredTextEditor [message #209966 is a reply to message #209958] Fri, 07 March 2008 15:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

Look at the XML Catalog extension point.

http://www.eclipse.org/webtools/community/tutorials/XMLCatal og/XMLCatalogTutorial.html

The other way is you might need to create a Custom Resolver that knows
about your XML markup, and loads the appropriate grammar. We use this
technique in the XSL Tooling incubating project, to specifically load a
particular version of a grammar based on the XSL verision attribute on
the stylesheet element. However, you still need to define the
namespace that the grammar should be attached too.




Alexandre Jaquet wrote:
> Hi David,
>
> There is no way to avoid the declaration in the xml file ? Like doing
> the content assist for a normal TextEditor ?
>
> http://wiki.eclipse.org/FAQ_How_do_I_add_Content_Assist_to_m y_editor%3F
> code sample
> http://www.google.com/codesearch?hl=en&q=show:7vc44WIFVK E:bhXBMftasZk:yC8Jo0ZNTP4&sa=N&ct=rd&cs_p=http:/ /devresource.hp.com/drc/technical_white_papers/eclipeditor/M yEditor3.zip&cs_f=MyEditor3/src/MyEditor/editors/MySourc eViewerConfig.java&start=1
>
>
> Regards
>
> Alexandre
Re: use custom xsd with the StructuredTextEditor [message #210109 is a reply to message #209966] Mon, 10 March 2008 13:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

I'm not sure if that can run correctly but I'm trying to hide a portion
of the document content

My document contains the following code

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xgui:module PUBLIC "-TOTO-" "unknown.dtd">
<xgui:module>
<xgui:hbox></xgui:hbox>
</xgui:module>

I want to hide the first two lines, I'm trying the following code

public void activateEditor() {
String str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE
xgui:module PUBLIC \"-TOTO-\" \"unknown.dtd\"";

boolean readOnly = true;
if (property != null) {
String v = property.getValue();
str = str.concat(v);
//str = v == null ? "" : v;
readOnly = false;
}

// Update the contents of the InputStreamEditorInput
InputStreamEditorInput input = (InputStreamEditorInput) getEditorInput();
InputStream is = new ByteArrayInputStream(str.getBytes());
input.setContents(is);
input.setReadOnly(readOnly);
getSourceViewer().getDocument().set(str);
String text = getSourceViewer().getDocument().get();
int length = getSourceViewer().getDocument().getLength();
getSourceViewer().setVisibleRegion(str.length(), length -1);
}

but my code is still visible :/ any idea why ?

(Do you think this solution will still enable the content assist)


Thanks

Alexandre
Re: use custom xsd with the StructuredTextEditor [message #210132 is a reply to message #210109] Mon, 10 March 2008 16:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

Well, there is one thing that stands out here to begin with. It looks
like you are trying to use namespaces with DTDs, which aren't supported.

http://www.rpbourret.com/xml/NamespacesFAQ.htm#dtd

The qualified support your are using in the DTD, is probably throwing
the processors for a loop as they may be thinking you are trying to do
namespaces. The qualifiers look like XML Namespace prefixes. So if
you can I would recommend migrating your DTD to a XML Schema.

A online service you can use to accomplish this is here:

http://www.hitsw.com/xml_utilites/

Dave


If you need namespace support you need to use XML Sck
Alexandre Jaquet wrote:
> I'm not sure if that can run correctly but I'm trying to hide a portion
> of the document content
>
> My document contains the following code
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE xgui:module PUBLIC "-TOTO-" "unknown.dtd">
> <xgui:module>
> <xgui:hbox></xgui:hbox>
> </xgui:module>
>
> I want to hide the first two lines, I'm trying the following code
>
> public void activateEditor() {
> String str = "<?xml version=\"1.0\"
> encoding=\"UTF-8\"?><!DOCTYPE xgui:module PUBLIC \"-TOTO-\"
> \"unknown.dtd\"";
>
> boolean readOnly = true;
> if (property != null) {
> String v = property.getValue();
> str = str.concat(v);
> //str = v == null ? "" : v;
> readOnly = false;
> }
>
> // Update the contents of the InputStreamEditorInput
> InputStreamEditorInput input = (InputStreamEditorInput)
> getEditorInput();
> InputStream is = new ByteArrayInputStream(str.getBytes());
> input.setContents(is);
> input.setReadOnly(readOnly);
> getSourceViewer().getDocument().set(str);
> String text = getSourceViewer().getDocument().get();
> int length = getSourceViewer().getDocument().getLength();
> getSourceViewer().setVisibleRegion(str.length(), length -1);
> }
>
> but my code is still visible :/ any idea why ?
>
> (Do you think this solution will still enable the content assist)
>
>
> Thanks
>
> Alexandre
Re: use custom xsd with the StructuredTextEditor [message #210140 is a reply to message #210109] Mon, 10 March 2008 21:11 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 2335
Registered: July 2009
Senior Member
Alexandre Jaquet wrote:
> I'm not sure if that can run correctly but I'm trying to hide a portion
> of the document content
>
> My document contains the following code
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE xgui:module PUBLIC "-TOTO-" "unknown.dtd">
> <xgui:module>
> <xgui:hbox></xgui:hbox>
> </xgui:module>
>
> I want to hide the first two lines, I'm trying the following code
>
> public void activateEditor() {
> String str = "<?xml version=\"1.0\"
> encoding=\"UTF-8\"?><!DOCTYPE xgui:module PUBLIC \"-TOTO-\"
> \"unknown.dtd\"";
>
> boolean readOnly = true;
> if (property != null) {
> String v = property.getValue();
> str = str.concat(v);
> //str = v == null ? "" : v;
> readOnly = false;
> }
>
> // Update the contents of the InputStreamEditorInput
> InputStreamEditorInput input = (InputStreamEditorInput)
> getEditorInput();
> InputStream is = new ByteArrayInputStream(str.getBytes());
> input.setContents(is);
> input.setReadOnly(readOnly);
> getSourceViewer().getDocument().set(str);
> String text = getSourceViewer().getDocument().get();
> int length = getSourceViewer().getDocument().getLength();
> getSourceViewer().setVisibleRegion(str.length(), length -1);
> }
>
> but my code is still visible :/ any idea why ?
>
> (Do you think this solution will still enable the content assist)

Content Assist shouldn't care, but you're getting the visible length
after having changed the document contents, so you're just cutting
off the last character of the new contents, str, at best. The best
solution would involve bug 210413, I think.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=210413

--
---
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: use custom xsd with the StructuredTextEditor [message #892655 is a reply to message #209886] Fri, 29 June 2012 02:07 Go to previous message
rohit chawla is currently offline rohit chawlaFriend
Messages: 19
Registered: June 2012
Junior Member
This is exactly, what I need. Alex wanted on DTD, I want to get assistance through xsd, but without specifying the schema location or namespace in the file.??

Is there a potensial solution to this problem?

Thanks.
Previous Topic:StructuredTextViewerConfigurationXML
Next Topic:Tomcat - Multiple Root Context
Goto Forum:
  


Current Time: Wed Nov 26 11:50:41 GMT 2014

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

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