Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » How to get line/col info for WSDLResource element(Where's WSDLParser used?)
How to get line/col info for WSDLResource element [message #630887] Tue, 05 October 2010 13:18 Go to next message
Robert Brodt is currently offline Robert BrodtFriend
Messages: 811
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

Hi all,

The BPEL editor needs to do some additional validation (i.e. resolving imports) so it needs access to the WSDL element line and column numbers. I see there's a WSDLParser class which (presumably if the TRACK_LOCATION option is TRUE) will report this info, but I can't seem to find where this class is actually used, much less how to get access to it. Can anyone help?

Thanks!
Bob
Re: How to get line/col info for WSDLResource element [message #630899 is a reply to message #630887] Tue, 05 October 2010 13:52 Go to previous messageGo to next message
Valentin Baciu is currently offline Valentin BaciuFriend
Messages: 6
Registered: July 2009
Junior Member
Hi Bob,

This function is modeled after the similar XSDParser from the XSD Infoset
model. As you've discovered, the parser is used when the track
TRACK_LOCATION option is set to TRUE. You can see the parser used to build
the DOM underlying the WSDL EMF model in the
org.eclipse.wst.wsdl.util.WSDLResourceImpl.getDocumentUsingS AX(InputSource,
Map).

As for how to use it to get a DOM element's location, you will code
something like this:

Element domElement = <wsdl EMF model object>.getElement();
int startLine = WSDLParser.getStartLine(element);
int startColumn = WSDLParser.getStartColumn(element);

Hope this helps, Valentin

"Bob Brodt" <bbrodt@redhat.com> wrote in message
news:i8f8dk$2ca$1@news.eclipse.org...
> Hi all,
>
> The BPEL editor needs to do some additional validation (i.e. resolving
> imports) so it needs access to the WSDL element line and column numbers. I
> see there's a WSDLParser class which (presumably if the TRACK_LOCATION
> option is TRUE) will report this info, but I can't seem to find where this
> class is actually used, much less how to get access to it. Can anyone
> help?
>
> Thanks!
> Bob
Re: How to get line/col info for WSDLResource element [message #630908 is a reply to message #630899] Tue, 05 October 2010 14:43 Go to previous messageGo to next message
Robert Brodt is currently offline Robert BrodtFriend
Messages: 811
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

Thanks Valentin! I should have realized this since WSDLParser is a utility class and all of its methods are static Wink

BTW, the javadocs I found for this package mention that this is a provisional API - how "provisional" is it and is it likely to change in the near future?

Thanks again,
Bob
Re: How to get line/col info for WSDLResource element [message #630937 is a reply to message #630908] Tue, 05 October 2010 15:17 Go to previous messageGo to next message
Valentin Baciu is currently offline Valentin BaciuFriend
Messages: 6
Registered: July 2009
Junior Member
You're welcome Bob. There are of course no hard guarantees, but I think
you're fairly safe to use it - I'm not aware of any plans to change this
class any time soon.

Cheers, Valentin

"Bob Brodt" <bbrodt@redhat.com> wrote in message
news:i8fddv$c0n$1@news.eclipse.org...
> Thanks Valentin! I should have realized this since WSDLParser is a utility
> class and all of its methods are static ;)
>
> BTW, the javadocs I found for this package mention that this is a
> provisional API - how "provisional" is it and is it likely to change in
> the near future?
>
> Thanks again,
> Bob
Re: How to get line/col info for WSDLResource element [message #630970 is a reply to message #630937] Tue, 05 October 2010 16:49 Go to previous messageGo to next message
Robert Brodt is currently offline Robert BrodtFriend
Messages: 811
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

Sorry for being so dense, but I can't seem to get this to work Sad

I have a WSDL that starts out like this:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions ...>
<types xmlns="http://schemas.xmlsoap.org/wsdl/">
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://www.example.org/" schemaLocation="some_invalid_location.xsd"/>
</schema>
</types>

and obviously, I'm trying to report the line/column of the missing import location. The WSDL Resource is part of a ResourceSet so I've set the load options to include "TRACK_LOCATION=true" like so:

Map opt = resSet.getLoadOptions();
opt.put("TRACK_LOCATION", Boolean.TRUE);

then the WSDL resource is created and loaded like so:

Resource res = resSet.createResource(uri, kind);
res.load(opt);

Then I navigate the model to get the imported XSD element:

Definition definition = res.getContents().get(0);
List<XSDSchema> schemas = definition.getETypes().getSchemas();
XSDSchemaContent sc = schemas.getContents().get(0);
int startLine = WSDLParser.getStartLine( sc.getElement() );
int startCol = WSDLParser.getStartColumn( sc.getElement() );

The startLine and startCol are always returned as 1/1 (likewise, end line/column are always the last character position in the WSDL file).

Also, the <definition> start line/column is reported as 1/1 (shouldn't the start line be 2?)

What am I missing here?
Re: How to get line/col info for WSDLResource element [message #630988 is a reply to message #630970] Tue, 05 October 2010 18:53 Go to previous message
Robert Brodt is currently offline Robert BrodtFriend
Messages: 811
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

Never mind - it turns out that I needed to get the line/column numbers from the XSDParser, not WSDLParser. It's working now. I guess the XSDParser is used for parsing <import> elements with xmlns="http://www.w3.org/2001/XMLSchema" (which makes sense)
Previous Topic:Problem to build Java source from wsdl
Next Topic:XML validation and markers
Goto Forum:
  


Current Time: Thu Mar 28 09:47:09 GMT 2024

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

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

Back to the top