[WikiText] Is it possible to extract attributes using WikiText [message #69727] |
Wed, 24 June 2009 10:53 |
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 17:25 |
David Green Messages: 136 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 17:25 |
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
|
|
|
Powered by
FUDForum. Page generated in 0.02929 seconds