Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Mylyn » [WikiText] Is it possible to extract attributes using WikiText
[WikiText] Is it possible to extract attributes using WikiText [message #69727] Wed, 24 June 2009 06:53 Go to next message
Eclipse User
Originally posted by: siluven.yahoo.ca

Hello everyone,
I am a new Mylyn user. I'm planning to work with Wiki Articles with java
and eclipse.

Is that possible to extract attributes like hyperlinks, headings, images,
etc. directly from e. g. wikimedia markup-language using WikiText.
like:
- obj.getHyperlinks();

If it is possible or maybe there is solutions for this, how could it be
done?

Thank you and best regards
Luven
Re: [WikiText] Is it possible to extract attributes using WikiText [message #69995 is a reply to message #69727] Tue, 30 June 2009 13:25 Go to previous message
David Green is currently offline David Green
Messages: 135
Registered: July 2009
Senior Member
siluven wrote:
> Hello everyone,
> I am a new Mylyn user. I'm planning to work with Wiki Articles with java
> and eclipse.
>
> Is that possible to extract attributes like hyperlinks, headings,
> images, etc. directly from e. g. wikimedia markup-language using WikiText.
> like:
> - obj.getHyperlinks();
>
> If it is possible or maybe there is solutions for this, how could it be
> done?
>
> Thank you and best regards
> Luven

This one was cross-posted to the Mylyn Integrators mailing list. Here's
the answer that I posted:

You want to do something like this:


public class ExtractHyperlinksBuilder extends NoOpDocumentBuilder {
private Set<String> hyperlinks = new HashSet<String>();

@Override
public void link(Attributes attributes, String hrefOrHashName, String
text) {
hyperlinks.add(hrefOrHashName);
}

@Override
public void imageLink(Attributes linkAttributes, Attributes
imageAttributes, String href, String imageUrl) {
hyperlinks.add(href);
}

public Set<String> getHyperlinks() {
return hyperlinks;
}

}



MarkupParser parser = new
MarkupParser(ServiceLocator.getInstance().getMarkupLanguage( "MediaWiki"));
ExtractHyperlinksBuilder builder = new ExtractHyperlinksBuilder();
parser.setBuilder(builder);

Reader markupContent = null;// open reader
try {
parser.parse(markupContent);
} finally {
markupContent.close();
}
// do something with builder.getHyperlinks()

Regards,

David
Re: [WikiText] Is it possible to extract attributes using WikiText [message #597956 is a reply to message #69727] Tue, 30 June 2009 13:25 Go to previous message
David Green is currently offline David Green
Messages: 96
Registered: July 2009
Member
siluven wrote:
> Hello everyone,
> I am a new Mylyn user. I'm planning to work with Wiki Articles with java
> and eclipse.
>
> Is that possible to extract attributes like hyperlinks, headings,
> images, etc. directly from e. g. wikimedia markup-language using WikiText.
> like:
> - obj.getHyperlinks();
>
> If it is possible or maybe there is solutions for this, how could it be
> done?
>
> Thank you and best regards
> Luven

This one was cross-posted to the Mylyn Integrators mailing list. Here's
the answer that I posted:

You want to do something like this:


public class ExtractHyperlinksBuilder extends NoOpDocumentBuilder {
private Set<String> hyperlinks = new HashSet<String>();

@Override
public void link(Attributes attributes, String hrefOrHashName, String
text) {
hyperlinks.add(hrefOrHashName);
}

@Override
public void imageLink(Attributes linkAttributes, Attributes
imageAttributes, String href, String imageUrl) {
hyperlinks.add(href);
}

public Set<String> getHyperlinks() {
return hyperlinks;
}

}



MarkupParser parser = new
MarkupParser(ServiceLocator.getInstance().getMarkupLanguage( "MediaWiki"));
ExtractHyperlinksBuilder builder = new ExtractHyperlinksBuilder();
parser.setBuilder(builder);

Reader markupContent = null;// open reader
try {
parser.parse(markupContent);
} finally {
markupContent.close();
}
// do something with builder.getHyperlinks()

Regards,

David
Previous Topic:Example bug with WikiText?
Next Topic:Example bug with WikiText?
Goto Forum:
  


Current Time: Fri Aug 29 20:25:13 EDT 2014

Powered by FUDForum. Page generated in 0.02789 seconds