Skip to main content


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 10:53 Go to next message
Eclipse UserFriend
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 Go to previous message
David Green is currently offline David GreenFriend
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 Go to previous message
David Green is currently offline David GreenFriend
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:Mylyn 3.2RC3 is now available
Next Topic:Mylyn 3.2 is now available
Goto Forum:
  


Current Time: Fri Apr 19 22:25:30 GMT 2024

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

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

Back to the top