-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
272 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package xml | ||
|
||
// Used in Textelr and SectionTa | ||
type LienArt struct { | ||
Debut string `xml:"debut,attr"` | ||
Etat string `xml:"etat,attr"` | ||
Fin string `xml:"fin,attr"` | ||
Id string `xml:"id,attr"` | ||
Num string `xml:"num,attr"` | ||
Origine string `xml:"origine,attr"` | ||
} | ||
|
||
// Used in Textelr and SectionTa | ||
type LienSectionTa struct { | ||
Cid string `xml:"cid,attr"` | ||
Debut string `xml:"debut,attr"` | ||
Etat string `xml:"etat,attr"` | ||
Fin string `xml:"fin,attr"` | ||
Id string `xml:"id,attr"` | ||
Niv string `xml:"niv,attr"` | ||
Url string `xml:"url,attr"` | ||
Contenu string `xml:",chardata"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package xml | ||
|
||
import ( | ||
"encoding/xml" | ||
"io/ioutil" | ||
) | ||
|
||
type SectionTa struct { | ||
XMLName xml.Name `xml:"SECTION_TA"` | ||
Id string `xml:"ID"` | ||
TitreTa string `xml:"TITRE_TA"` | ||
Commentaire string `xml:"COMMENTAIRE"` | ||
LiensArt []LienArt `xml:"STRUCTURE_TA>LIEN_ART"` | ||
LiensSectionTa []LienSectionTa `xml:"STRUCTURE_TA>LIEN_SECTION_TA"` | ||
Contexte Contexte `xml:"CONTEXTE>TEXTE"` | ||
} | ||
|
||
type Contexte struct { | ||
Autorite string `xml:"autorite,attr"` | ||
Cid string `xml:"cid,attr"` | ||
DatePubli string `xml:"date_publi,attr"` | ||
DateSignature string `xml:"date_signature,attr"` | ||
Ministere string `xml:"ministere,attr"` | ||
Nature string `xml:"nature,attr"` | ||
Nor string `xml:"nor,attr"` | ||
Num string `xml:"num,attr"` | ||
TitreTxt TitreTxt `xml:"TITRE_TXT"` | ||
Tm Tm `xml:"TM"` | ||
} | ||
|
||
type TitreTxt struct { | ||
CTitreCourt string `xml:"c_titre_court,attr"` | ||
Debut string `xml:"debut,attr"` | ||
Fin string `xml:"fin,attr"` | ||
IdTxt string `xml:"id_txt,attr"` | ||
Contenu string `xml:",chardata"` | ||
} | ||
|
||
type Tm struct { | ||
TitreTm TitreTm `xml:"TITRE_TM"` | ||
Tm *Tm `xml:"TM"` | ||
} | ||
|
||
type TitreTm struct { | ||
Debut string `xml:"debut,attr"` | ||
Fin string `xml:"fin,attr"` | ||
Id string `xml:"id,attr"` | ||
Contenu string `xml:",chardata"` | ||
} | ||
|
||
func DecodeSectionTa(filename string) (*SectionTa, error) { | ||
|
||
content, err := ioutil.ReadFile(filename) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var v SectionTa | ||
err = xml.Unmarshal(content, &v) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &v, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package xml | ||
|
||
import ( | ||
// "fmt" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestDecodeSectionTaUnknown(t *testing.T) { | ||
f := "specs/notfound.xml" | ||
_, err := DecodeSectionTa(f) | ||
if err == nil { | ||
t.Errorf("Error unhandled not found file") | ||
} | ||
} | ||
|
||
func TestDecodeSectionTaInvalid(t *testing.T) { | ||
f := "specs/texte_version_LEGITEXT000005627819.xml" | ||
_, err := DecodeSectionTa(f) | ||
if err == nil { | ||
t.Errorf("Error unhandled invalid file") | ||
} | ||
} | ||
|
||
func TestDecodeSectionTa1(t *testing.T) { | ||
f := "specs/section_ta_LEGISCTA000006083673.xml" | ||
v, err := DecodeSectionTa(f) | ||
if err != nil { | ||
t.Errorf("Error decoding file") | ||
return | ||
} | ||
|
||
assertStringEquals(t, "LEGISCTA000006083673", v.Id) | ||
assertStringEquals(t, "Partie législative", v.TitreTa) | ||
assertStringEquals(t, "", v.Commentaire) | ||
|
||
assertLenEquals(t, 0, len(v.LiensArt)) | ||
assertLenEquals(t, 5, len(v.LiensSectionTa)) | ||
} | ||
|
||
func TestDecodeSectionTa2(t *testing.T) { | ||
f := "specs/section_ta_LEGISCTA000029502487.xml" | ||
v, err := DecodeSectionTa(f) | ||
if err != nil { | ||
t.Errorf("Error decoding file") | ||
return | ||
} | ||
|
||
assertStringEquals(t, "LEGISCTA000029502487", v.Id) | ||
assertStringEquals(t, "Section 6 : Action de groupe intervenant dans le domaine de la concurrence", v.TitreTa) | ||
assertStringEquals(t, "Néant", v.Commentaire) | ||
|
||
assertLenEquals(t, 0, len(v.LiensArt)) | ||
assertLenEquals(t, 0, len(v.LiensSectionTa)) | ||
} | ||
|
||
func TestDecodeSectionTa3(t *testing.T) { | ||
f := "specs/section_ta_LEGISCTA000029502492.xml" | ||
v, err := DecodeSectionTa(f) | ||
if err != nil { | ||
t.Errorf("Error decoding file") | ||
return | ||
} | ||
|
||
assertStringEquals(t, "LEGISCTA000029502492", v.Id) | ||
assertStringEquals(t, "Section 1 : Dispositions préliminaires ", v.TitreTa) | ||
assertStringEquals(t, "", v.Commentaire) | ||
|
||
assertLenEquals(t, 5, len(v.LiensArt)) | ||
assertLenEquals(t, 0, len(v.LiensSectionTa)) | ||
|
||
assertStringEquals(t, "", v.Contexte.Autorite) | ||
assertStringEquals(t, "LEGITEXT000006069565", v.Contexte.Cid) | ||
assertStringEquals(t, "2999-01-01", v.Contexte.DatePubli) | ||
assertStringEquals(t, "2999-01-01", v.Contexte.DateSignature) | ||
assertStringEquals(t, "", v.Contexte.Ministere) | ||
assertStringEquals(t, "CODE", v.Contexte.Nature) | ||
assertStringEquals(t, "", v.Contexte.Nor) | ||
assertStringEquals(t, "", v.Contexte.Num) | ||
|
||
assertStringEquals(t, "Code de la consommation", v.Contexte.TitreTxt.CTitreCourt) | ||
assertStringEquals(t, "1993-07-27", v.Contexte.TitreTxt.Debut) | ||
assertStringEquals(t, "2999-01-01", v.Contexte.TitreTxt.Fin) | ||
assertStringEquals(t, "LEGITEXT000006069565", v.Contexte.TitreTxt.IdTxt) | ||
assertStringEquals(t, "Code de la consommation", v.Contexte.TitreTxt.Contenu) | ||
|
||
assertStringEquals(t, "1997-04-03", v.Contexte.Tm.TitreTm.Debut) | ||
assertStringEquals(t, "2016-10-01", v.Contexte.Tm.TitreTm.Fin) | ||
assertStringEquals(t, "LEGISCTA000006084139", v.Contexte.Tm.TitreTm.Id) | ||
assertStringEquals(t, "Partie réglementaire", | ||
v.Contexte.Tm.TitreTm.Contenu) | ||
assertStringEquals(t, "Livre IV : Les associations de consommateurs", | ||
v.Contexte.Tm.Tm.TitreTm.Contenu) | ||
assertStringEquals(t, "Titre II : Action en justice des associations.", | ||
v.Contexte.Tm.Tm.Tm.TitreTm.Contenu) | ||
assertStringEquals(t, `Chapitre III : Action de groupe`, | ||
strings.TrimSpace(v.Contexte.Tm.Tm.Tm.Tm.TitreTm.Contenu)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<SECTION_TA> | ||
<ID>LEGISCTA000006083673</ID> | ||
<TITRE_TA>Partie législative</TITRE_TA> | ||
<STRUCTURE_TA> | ||
<LIEN_SECTION_TA cid="LEGISCTA000006114031" debut="1992-07-03" etat="VIGUEUR" fin="2999-01-01" id="LEGISCTA000006114031" niv="2" url="/LEGI/SCTA/00/00/06/11/40/LEGISCTA000006114031.xml">Première partie : La propriété littéraire et artistique</LIEN_SECTION_TA> | ||
<LIEN_SECTION_TA cid="LEGISCTA000006114032" debut="1992-07-03" etat="VIGUEUR" fin="2999-01-01" id="LEGISCTA000006114032" niv="2" url="/LEGI/SCTA/00/00/06/11/40/LEGISCTA000006114032.xml">Deuxième partie : La propriété industrielle</LIEN_SECTION_TA> | ||
<LIEN_SECTION_TA cid="LEGISCTA000006114035" debut="2001-07-28" etat="MODIFIE" fin="2014-03-13" id="LEGISCTA000006114035" niv="2" url="/LEGI/SCTA/00/00/06/11/40/LEGISCTA000006114035.xml">Troisième partie : Application aux territoires d'outre-mer et à Mayotte</LIEN_SECTION_TA> | ||
<LIEN_SECTION_TA cid="LEGISCTA000006114035" debut="2014-03-13" etat="VIGUEUR" fin="2999-01-01" id="LEGISCTA000028717135" niv="2" url="/LEGI/SCTA/00/00/28/71/71/LEGISCTA000028717135.xml">Troisième partie : Dispositions relatives à l'outre-mer</LIEN_SECTION_TA> | ||
<LIEN_SECTION_TA cid="LEGISCTA000006114034" debut="1992-07-03" etat="ABROGE" fin="2006-06-02" id="LEGISCTA000006114034" niv="2" url="/LEGI/SCTA/00/00/06/11/40/LEGISCTA000006114034.xml">Troisième partie : Application aux territoires d'outre-mer et à la collectivité territoriale de Mayotte</LIEN_SECTION_TA> | ||
</STRUCTURE_TA> | ||
<CONTEXTE> | ||
<TEXTE autorite="" cid="LEGITEXT000006069414" date_publi="2999-01-01" date_signature="2999-01-01" ministere="" nature="CODE" nor="" num=""> | ||
<TITRE_TXT c_titre_court="Code de la propriété intellectuelle" debut="1992-07-03" fin="2999-01-01" id_txt="LEGITEXT000006069414">Code de la propriété intellectuelle</TITRE_TXT> | ||
</TEXTE> | ||
</CONTEXTE> | ||
</SECTION_TA> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<SECTION_TA> | ||
<ID>LEGISCTA000029502487</ID> | ||
<TITRE_TA>Section 6 : Action de groupe intervenant dans le domaine de la concurrence</TITRE_TA> | ||
<COMMENTAIRE>Néant</COMMENTAIRE> | ||
<STRUCTURE_TA/> | ||
<CONTEXTE> | ||
<TEXTE autorite="" cid="LEGITEXT000006069565" date_publi="2999-01-01" date_signature="2999-01-01" ministere="" nature="CODE" nor="" num=""> | ||
<TITRE_TXT c_titre_court="Code de la consommation" debut="1993-07-27" fin="2999-01-01" id_txt="LEGITEXT000006069565">Code de la consommation</TITRE_TXT> | ||
<TM> | ||
<TITRE_TM debut="1997-04-03" fin="2016-10-01" id="LEGISCTA000006084139">Partie réglementaire</TITRE_TM> | ||
<TM> | ||
<TITRE_TM debut="1997-04-03" fin="2016-07-01" id="LEGISCTA000006114381">Livre IV : Les associations de consommateurs</TITRE_TM> | ||
<TM> | ||
<TITRE_TM debut="1997-04-03" fin="2016-07-01" id="LEGISCTA000006133649">Titre II : Action en justice des associations.</TITRE_TM> | ||
<TM> | ||
<TITRE_TM debut="2014-10-01" fin="2016-07-01" id="LEGISCTA000029502540">Chapitre III : Action de groupe | ||
| ||
</TITRE_TM> | ||
</TM> | ||
</TM> | ||
</TM> | ||
</TM> | ||
</TEXTE> | ||
</CONTEXTE> | ||
</SECTION_TA> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<SECTION_TA> | ||
<ID>LEGISCTA000029502492</ID> | ||
<TITRE_TA>Section 1 : Dispositions préliminaires </TITRE_TA> | ||
<STRUCTURE_TA> | ||
<LIEN_ART debut="2014-10-01" etat="ABROGE" fin="2016-07-01" id="LEGIARTI000029500450" num="R423-1" origine="LEGI"/> | ||
<LIEN_ART debut="2014-10-01" etat="ABROGE" fin="2016-07-01" id="LEGIARTI000029500452" num="R423-2" origine="LEGI"/> | ||
<LIEN_ART debut="2014-10-01" etat="ABROGE" fin="2016-07-01" id="LEGIARTI000029500454" num="R423-3" origine="LEGI"/> | ||
<LIEN_ART debut="2014-10-01" etat="ABROGE" fin="2016-07-01" id="LEGIARTI000029500456" num="R423-4" origine="LEGI"/> | ||
<LIEN_ART debut="2014-10-01" etat="ABROGE" fin="2016-07-01" id="LEGIARTI000029500458" num="R423-5" origine="LEGI"/> | ||
</STRUCTURE_TA> | ||
<CONTEXTE> | ||
<TEXTE autorite="" cid="LEGITEXT000006069565" date_publi="2999-01-01" date_signature="2999-01-01" ministere="" nature="CODE" nor="" num=""> | ||
<TITRE_TXT c_titre_court="Code de la consommation" debut="1993-07-27" fin="2999-01-01" id_txt="LEGITEXT000006069565">Code de la consommation</TITRE_TXT> | ||
<TM> | ||
<TITRE_TM debut="1997-04-03" fin="2016-10-01" id="LEGISCTA000006084139">Partie réglementaire</TITRE_TM> | ||
<TM> | ||
<TITRE_TM debut="1997-04-03" fin="2016-07-01" id="LEGISCTA000006114381">Livre IV : Les associations de consommateurs</TITRE_TM> | ||
<TM> | ||
<TITRE_TM debut="1997-04-03" fin="2016-07-01" id="LEGISCTA000006133649">Titre II : Action en justice des associations.</TITRE_TM> | ||
<TM> | ||
<TITRE_TM debut="2014-10-01" fin="2016-07-01" id="LEGISCTA000029502540">Chapitre III : Action de groupe | ||
| ||
</TITRE_TM> | ||
</TM> | ||
</TM> | ||
</TM> | ||
</TM> | ||
</TEXTE> | ||
</CONTEXTE> | ||
</SECTION_TA> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters