commit
899799b51b
|
@ -21,6 +21,7 @@ type Channel struct {
|
||||||
Items []*Item
|
Items []*Item
|
||||||
Cloud Cloud
|
Cloud Cloud
|
||||||
TextInput Input
|
TextInput Input
|
||||||
|
Extensions map[string]map[string][]Extension
|
||||||
|
|
||||||
// Atom fields
|
// Atom fields
|
||||||
Id string
|
Id string
|
||||||
|
|
55
feed_test.go
55
feed_test.go
|
@ -76,6 +76,61 @@ func Test_RssAuthor(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ItemExtensions(t *testing.T) {
|
||||||
|
content, _ := ioutil.ReadFile("testdata/extension.rss")
|
||||||
|
feed := New(1, true, chanHandler, itemHandler)
|
||||||
|
feed.FetchBytes("http://example.com", content, nil)
|
||||||
|
|
||||||
|
edgarExtensionxbrlFiling := feed.Channels[0].Items[0].Extensions["http://www.sec.gov/Archives/edgar"]["xbrlFiling"][0].Childrens
|
||||||
|
companyExpected := "Cellular Biomedicine Group, Inc."
|
||||||
|
companyName := edgarExtensionxbrlFiling["companyName"][0]
|
||||||
|
if companyName.Value != companyExpected {
|
||||||
|
t.Errorf("Expected company to be %s but found %s", companyExpected, companyName.Value)
|
||||||
|
}
|
||||||
|
|
||||||
|
files := edgarExtensionxbrlFiling["xbrlFiles"][0].Childrens["xbrlFile"]
|
||||||
|
fileSizeExpected := 10
|
||||||
|
if len(files) != 10 {
|
||||||
|
t.Errorf("Expected files size to be %s but found %s", fileSizeExpected, len(files))
|
||||||
|
}
|
||||||
|
|
||||||
|
file := files[0]
|
||||||
|
fileExpected := "cbmg_10qa.htm"
|
||||||
|
if file.Attrs["file"] != fileExpected {
|
||||||
|
t.Errorf("Expected file to be %s but found %s", fileExpected, len(file.Attrs["file"]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_ChannelExtensions(t *testing.T) {
|
||||||
|
content, _ := ioutil.ReadFile("testdata/extension.rss")
|
||||||
|
feed := New(1, true, chanHandler, itemHandler)
|
||||||
|
feed.FetchBytes("http://example.com", content, nil)
|
||||||
|
|
||||||
|
channel := feed.Channels[0]
|
||||||
|
itunesExtentions := channel.Extensions["http://www.itunes.com/dtds/podcast-1.0.dtd"]
|
||||||
|
|
||||||
|
authorExptected := "The Author"
|
||||||
|
ownerEmailExpected := "test@rss.com"
|
||||||
|
categoryExpected := "Politics"
|
||||||
|
imageExptected := "http://golang.org/doc/gopher/project.png"
|
||||||
|
|
||||||
|
if itunesExtentions["author"][0].Value != authorExptected {
|
||||||
|
t.Errorf("Expected author to be %s but found %s", authorExptected, itunesExtentions["author"][0].Value)
|
||||||
|
}
|
||||||
|
|
||||||
|
if itunesExtentions["owner"][0].Childrens["email"][0].Value != ownerEmailExpected {
|
||||||
|
t.Errorf("Expected owner email to be %s but found %s", ownerEmailExpected, itunesExtentions["owner"][0].Childrens["email"][0].Value)
|
||||||
|
}
|
||||||
|
|
||||||
|
if itunesExtentions["category"][0].Attrs["text"] != categoryExpected {
|
||||||
|
t.Errorf("Expected category text to be %s but found %s", categoryExpected, itunesExtentions["category"][0].Attrs["text"])
|
||||||
|
}
|
||||||
|
|
||||||
|
if itunesExtentions["image"][0].Attrs["href"] != imageExptected {
|
||||||
|
t.Errorf("Expected image href to be %s but found %s", imageExptected, itunesExtentions["image"][0].Attrs["href"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func Test_CData(t *testing.T) {
|
func Test_CData(t *testing.T) {
|
||||||
content, _ := ioutil.ReadFile("testdata/iosBoardGameGeek.rss")
|
content, _ := ioutil.ReadFile("testdata/iosBoardGameGeek.rss")
|
||||||
feed := New(1, true, chanHandler, itemHandler)
|
feed := New(1, true, chanHandler, itemHandler)
|
||||||
|
|
2
item.go
2
item.go
|
@ -23,6 +23,8 @@ type Item struct {
|
||||||
Generator *Generator
|
Generator *Generator
|
||||||
Contributors []string
|
Contributors []string
|
||||||
Content *Content
|
Content *Content
|
||||||
|
|
||||||
|
Extensions map[string]map[string][]Extension
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Item) Key() string {
|
func (i *Item) Key() string {
|
||||||
|
|
60
rss.go
60
rss.go
|
@ -6,6 +6,13 @@ import (
|
||||||
xmlx "github.com/jteeuwen/go-pkg-xmlx"
|
xmlx "github.com/jteeuwen/go-pkg-xmlx"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Extension struct {
|
||||||
|
Name string
|
||||||
|
Value string
|
||||||
|
Attrs map[string]string
|
||||||
|
Childrens map[string][]Extension
|
||||||
|
}
|
||||||
|
|
||||||
var days = map[string]int{
|
var days = map[string]int{
|
||||||
"Monday": 1,
|
"Monday": 1,
|
||||||
"Tuesday": 2,
|
"Tuesday": 2,
|
||||||
|
@ -189,9 +196,62 @@ func (this *Feed) readRss2(doc *xmlx.Document) (err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tl = item.SelectNodes(ns, ns)
|
||||||
|
i.Extensions = make(map[string]map[string][]Extension)
|
||||||
|
for _, lv := range tl {
|
||||||
|
getExtensions(&i.Extensions, lv)
|
||||||
|
}
|
||||||
|
|
||||||
ch.Items = append(ch.Items, i)
|
ch.Items = append(ch.Items, i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
x := node.SelectNodes(ns, ns)
|
||||||
|
ch.Extensions = make(map[string]map[string][]Extension)
|
||||||
|
for _, v := range x {
|
||||||
|
if v.Name.Space != "" {
|
||||||
|
getExtensions(&ch.Extensions, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
this.Channels = foundChannels
|
this.Channels = foundChannels
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getExtensions(extensionsX *map[string]map[string][]Extension, node *xmlx.Node) {
|
||||||
|
extentions := *extensionsX
|
||||||
|
|
||||||
|
if node.Name.Space != "" {
|
||||||
|
extensione, noErrors := getExtension(node)
|
||||||
|
if noErrors {
|
||||||
|
if len(extentions[node.Name.Space]) == 0 {
|
||||||
|
extentions[node.Name.Space] = make(map[string][]Extension, 0)
|
||||||
|
}
|
||||||
|
if len(extentions[node.Name.Space][node.Name.Local]) == 0 {
|
||||||
|
extentions[node.Name.Space][node.Name.Local] = make([]Extension, 0)
|
||||||
|
}
|
||||||
|
extentions[node.Name.Space][node.Name.Local] = append(extentions[node.Name.Space][node.Name.Local], extensione)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getExtension(node *xmlx.Node) (Extension, bool) {
|
||||||
|
var extension Extension
|
||||||
|
if node.Name.Space != "" {
|
||||||
|
extension = Extension{Name: node.Name.Local, Value: node.GetValue()}
|
||||||
|
extension.Attrs = make(map[string]string)
|
||||||
|
extension.Childrens = make(map[string][]Extension, 0)
|
||||||
|
for _, x := range node.Attributes {
|
||||||
|
extension.Attrs[x.Name.Local] = x.Value
|
||||||
|
}
|
||||||
|
for _, y := range node.Children {
|
||||||
|
children, ok := getExtension(y)
|
||||||
|
if ok {
|
||||||
|
extension.Childrens[y.Name.Local] = append(extension.Childrens[y.Name.Local], children)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return extension, true
|
||||||
|
} else {
|
||||||
|
return extension, false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
|
||||||
|
<channel>
|
||||||
|
<title>Extensions Test</title>
|
||||||
|
<link>http://test.extensions.net</link>
|
||||||
|
<description>Just a Test</description>
|
||||||
|
<language>en-US</language>
|
||||||
|
<lastBuildDate>Wed, 27 Mar 2013 12:30:18 PDT</lastBuildDate>
|
||||||
|
<image>
|
||||||
|
<link>http://test.extensions.net</link>
|
||||||
|
<url>http://test.extensions.net/test.jpg</url>
|
||||||
|
<title>Extensions Test</title>
|
||||||
|
</image>
|
||||||
|
<itunes:author>The Author</itunes:author>
|
||||||
|
<itunes:owner>
|
||||||
|
<itunes:name></itunes:name>
|
||||||
|
<itunes:email>test@rss.com</itunes:email>
|
||||||
|
</itunes:owner>
|
||||||
|
<itunes:category text="Politics"></itunes:category>
|
||||||
|
<itunes:image href="http://golang.org/doc/gopher/project.png" />
|
||||||
|
<item>
|
||||||
|
<title>Cellular Biomedicine Group, Inc. (0001378624) (Filer)</title>
|
||||||
|
<link>http://www.sec.gov/Archives/edgar/data/1378624/000135448813006749/0001354488-13-006749-index.htm</link>
|
||||||
|
<guid>http://www.sec.gov/Archives/edgar/data/1378624/000135448813006749/0001354488-13-006749-xbrl.zip</guid>
|
||||||
|
<enclosure url="http://www.sec.gov/Archives/edgar/data/1378624/000135448813006749/0001354488-13-006749-xbrl.zip" length="133879" type="application/zip" />
|
||||||
|
<description>10-Q/A</description>
|
||||||
|
<pubDate>Fri, 06 Dec 2013 17:29:22 EST</pubDate>
|
||||||
|
<edgar:xbrlFiling xmlns:edgar="http://www.sec.gov/Archives/edgar">
|
||||||
|
<edgar:companyName>Cellular Biomedicine Group, Inc.</edgar:companyName>
|
||||||
|
<edgar:formType>10-Q/A</edgar:formType>
|
||||||
|
<edgar:filingDate>12/06/2013</edgar:filingDate>
|
||||||
|
<edgar:cikNumber>0001378624</edgar:cikNumber>
|
||||||
|
<edgar:accessionNumber>0001354488-13-006749</edgar:accessionNumber>
|
||||||
|
<edgar:fileNumber>000-52282</edgar:fileNumber>
|
||||||
|
<edgar:acceptanceDatetime>20131206172922</edgar:acceptanceDatetime>
|
||||||
|
<edgar:period>20130630</edgar:period>
|
||||||
|
<edgar:assistantDirector>7</edgar:assistantDirector>
|
||||||
|
<edgar:assignedSic>6199</edgar:assignedSic>
|
||||||
|
<edgar:fiscalYearEnd>1231</edgar:fiscalYearEnd>
|
||||||
|
<edgar:xbrlFiles>
|
||||||
|
<edgar:xbrlFile edgar:sequence="1" edgar:file="cbmg_10qa.htm" edgar:type="10-Q/A" edgar:size="2367019" edgar:description="CURRENT REPORT AMENDMENT" edgar:url="http://www.sec.gov/Archives/edgar/data/1378624/000135448813006749/cbmg_10qa.htm" />
|
||||||
|
<edgar:xbrlFile edgar:sequence="2" edgar:file="cbmg_ex311.htm" edgar:type="EX-31.1" edgar:size="19198" edgar:description="CERTIFICATION" edgar:url="http://www.sec.gov/Archives/edgar/data/1378624/000135448813006749/cbmg_ex311.htm" />
|
||||||
|
<edgar:xbrlFile edgar:sequence="3" edgar:file="cbmg_ex312.htm" edgar:type="EX-31.2" edgar:size="18548" edgar:description="CERTIFICATION" edgar:url="http://www.sec.gov/Archives/edgar/data/1378624/000135448813006749/cbmg_ex312.htm" />
|
||||||
|
<edgar:xbrlFile edgar:sequence="4" edgar:file="cbmg_ex321.htm" edgar:type="EX-32.1" edgar:size="9490" edgar:description="CERTIFICATION" edgar:url="http://www.sec.gov/Archives/edgar/data/1378624/000135448813006749/cbmg_ex321.htm" />
|
||||||
|
<edgar:xbrlFile edgar:sequence="5" edgar:file="cmbg-20130630.xml" edgar:type="EX-101.INS" edgar:size="1535753" edgar:description="" edgar:url="http://www.sec.gov/Archives/edgar/data/1378624/000135448813006749/cmbg-20130630.xml" />
|
||||||
|
<edgar:xbrlFile edgar:sequence="6" edgar:file="cmbg-20130630.xsd" edgar:type="EX-101.SCH" edgar:size="48804" edgar:description="" edgar:url="http://www.sec.gov/Archives/edgar/data/1378624/000135448813006749/cmbg-20130630.xsd" />
|
||||||
|
<edgar:xbrlFile edgar:sequence="7" edgar:file="cmbg-20130630_cal.xml" edgar:type="EX-101.CAL" edgar:size="60044" edgar:description="" edgar:url="http://www.sec.gov/Archives/edgar/data/1378624/000135448813006749/cmbg-20130630_cal.xml" />
|
||||||
|
<edgar:xbrlFile edgar:sequence="8" edgar:file="cmbg-20130630_def.xml" edgar:type="EX-101.DEF" edgar:size="138211" edgar:description="" edgar:url="http://www.sec.gov/Archives/edgar/data/1378624/000135448813006749/cmbg-20130630_def.xml" />
|
||||||
|
<edgar:xbrlFile edgar:sequence="9" edgar:file="cmbg-20130630_lab.xml" edgar:type="EX-101.LAB" edgar:size="264038" edgar:description="" edgar:url="http://www.sec.gov/Archives/edgar/data/1378624/000135448813006749/cmbg-20130630_lab.xml" />
|
||||||
|
<edgar:xbrlFile edgar:sequence="10" edgar:file="cmbg-20130630_pre.xml" edgar:type="EX-101.PRE" edgar:size="247808" edgar:description="" edgar:url="http://www.sec.gov/Archives/edgar/data/1378624/000135448813006749/cmbg-20130630_pre.xml" />
|
||||||
|
</edgar:xbrlFiles>
|
||||||
|
</edgar:xbrlFiling>
|
||||||
|
</item>
|
||||||
|
</channel>
|
||||||
|
|
Loading…
Reference in New Issue