java.lang.Object
org.xml.sax.helpers.XMLFilterImpl
org.esau.ptarmigan.impl.filter.BaseFilter
org.esau.ptarmigan.impl.filter.PlaylistFilter
org.esau.ptarmigan.impl.filter.XMLPlaylistFilter
org.esau.ptarmigan.impl.filter.B4SFilter
- All Implemented Interfaces:
- org.esau.ptarmigan.impl.CharacterStreamSource, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.XMLFilter, org.xml.sax.XMLReader
- public final class B4SFilter
- extends XMLPlaylistFilter
B4SFilter -- transforms B4S playlist to ptarmigan playlist
Example source:
<?xml version="1.0" encoding='UTF-8' standalone="yes"?>
<WinampXML>
<!- Generated by: Nullsoft Winamp3 version 3.0 ->
<playlist num_entries="4" label="Playlist 001">
<entry Playstring="file:C:\work\java\ptarmigan\ptarmigan\test\none.mp3">
<Name>none</Name>
<Length>2247</Length>
</entry>
<entry Playstring="file:C:\music\Jazz\Vocals\Billie Holiday\Body and Soul\01 - Body And Soul.mp3">
<Name>Billie Holiday - Body And Soul</Name>
<Length>383530</Length>
</entry>
<entry Playstring="file:C:\music\Jazz\Vocals\Billie Holiday\Body and Soul\02 - They Can't Take That Away From Me.mp3">
<Name>Billie Holiday - They Can't Take That Away From Me</Name>
<Length>252500</Length>
</entry>
<entry Playstring="file:C:\music\Jazz\Vocals\Billie Holiday\Body and Soul\03 - Darn That Dream.mp3">
<Name>Billie Holiday - Darn That Dream</Name>
<Length>379481</Length>
</entry>
</playlist>
</WinampXML>
The equivalent XSLT would appear thus:
<xsl:stylesheet version="1.0"
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:pl='http://esau.org/ns/ptarmigan/playlist'>
<xsl:param name='include_entries'/>
<xsl:param name='file_separator'/>
<xsl:template match="/WinampXML/playlist">
<pl:playlist>
<pl:properties>
<pl:title><xsl:value-of select='@label'/></pl:title>
<pl:entry-count><xsl:value-of select='count(./entry)'/></pl:entry-count>
<pl:duration-total><xsl:value-of select='sum(./entry/Length)'/></pl:duration-total>
</pl:properties>
<xsl:if test="$include_entries = 'true'">
<xsl:apply-templates select="entry"/>
</xsl:if>
</pl:playlist>
</xsl:template>
<xsl:template match="entry">
<pl:entry>
<pl:path><xsl:value-of select='@Playstring'/></pl:path>
<pl:title><xsl:value-of select='Name'/></pl:title>
<pl:duration><xsl:value-of select='Length'/></pl:duration>
</pl:entry>
</xsl:template>
</xsl:stylesheet>
TODO: recursively scan all playlists found.
- Version:
- $Revision: 1.2 $ $Date: 2002/09/16 04:05:07 $
Fields inherited from class org.esau.ptarmigan.impl.filter.PlaylistFilter |
NS_PREFIX, NS_URI, TAG_ENTRY, TAG_ENTRY_DURATION, TAG_ENTRY_TITLE, TAG_ENTRY_URL, TAG_PLAYLIST, TAG_PROPS, TAG_PROPS_AUTHOR, TAG_PROPS_COPYRIGHT, TAG_PROPS_DURATION_TOTAL, TAG_PROPS_ENTRY_COUNT, TAG_PROPS_SUMMARY, TAG_PROPS_TITLE |
Methods inherited from class org.esau.ptarmigan.impl.filter.PlaylistFilter |
endPlaylist, getIncludeEntries, getInEntry, getIsPropsDone, getNamespacePrefix, getNamespaceURI, resetData, setAuthor, setBaseDir, setCopyright, setEntryCount, setEntryDuration, setEntryPath, setEntryPath, setEntryTitle, setIncludeEntries, setInEntry, setSummary, setTitle, startPlaylist, writeEntry, writeProperties |
Methods inherited from class org.esau.ptarmigan.impl.filter.BaseFilter |
characters, getByteStream, getChars, getMediaProperties, parse, setMediaProperties, write, write, write, write, write, write, write, write, write, write, write, writeDate, writeDate, writeDate, writeDate, writeInteger, writeInteger, writeInteger, writeInteger, writeInteger, writeString, writeString, writeString, writeString, writeString |
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl |
endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
B4S
static final java.lang.String B4S
- from the b4s 'structure'
- See Also:
- Constant Field Values
B4S_PLAYLIST
static final java.lang.String B4S_PLAYLIST
- See Also:
- Constant Field Values
B4S_NUM_ENTRIES
static final java.lang.String B4S_NUM_ENTRIES
- See Also:
- Constant Field Values
B4S_LABEL
static final java.lang.String B4S_LABEL
- See Also:
- Constant Field Values
B4S_ENTRY
static final java.lang.String B4S_ENTRY
- See Also:
- Constant Field Values
B4S_ENTRY_PLAYSTRING
static final java.lang.String B4S_ENTRY_PLAYSTRING
- See Also:
- Constant Field Values
B4S_ENTRY_NAME
static final java.lang.String B4S_ENTRY_NAME
- See Also:
- Constant Field Values
B4S_ENTRY_LENGTH
static final java.lang.String B4S_ENTRY_LENGTH
- See Also:
- Constant Field Values
log
static org.apache.commons.logging.Log log
- logging object
B4SFilter
public B4SFilter()
throws org.xml.sax.SAXException
isMatch
public boolean isMatch(java.lang.String sniff_chars)
- is the root element of the xml file indicate it's WinampXML?
Note: do B4S files have namespaces?
- Specified by:
isMatch
in class PlaylistFilter
startElement
public void startElement(java.lang.String uri,
java.lang.String local_name,
java.lang.String qName,
org.xml.sax.Attributes atts)
throws org.xml.sax.SAXException
- Filter a start element event.
endElement
public void endElement(java.lang.String uri,
java.lang.String local_name,
java.lang.String qName)
throws org.xml.sax.SAXException
- Filter an end element event.