Skip to content

Commit 2e74ba8

Browse files
committed
add samples using xslt
1 parent 57d23a5 commit 2e74ba8

File tree

18 files changed

+491
-0
lines changed

18 files changed

+491
-0
lines changed

examples/personal-data/input/birth/birth-test-data2.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bc-city-or-municipality,bc-province,bc-registry-number,bc-child-firstname,bc-child-middlename,bc-child-lastname,bc-child-sex,bc-child-bp-city-or-municipality,bc-child-bp-province,bc-chilc-dob,bc-mother-mn-firstname,bc-mother-mn-middlename,bc-mother-mn-lastname,bc-mother-citizenship,bc-mother-religion,bc-mother-occupation,bc-mother-residence-city-or-municipality,bc-mother-residence-province,bc-father-firstname,bc-father-middlename,bc-father-lastname,bc-father-citizenship,bc-father-religion,bc-father-occupation,bc-mop-date,bc-mop-place,bc-attendantMandaluyong City,Metro Manila,1001,Isabel,Portacio,Molina,F,Mandaluyong City,Metro Manila,03/11/02,Isabel,Quadro,Portacio,Filipino,Roman Catholic,Housewife,Tayabas,Quezon,Job,Robredo,Molina,Filipino,Roman Catholic,Farmer,,,Sorsogon,Sorsogon,1002,Juan Miguel,Esquivel,Ramos,M,Sorsogon,Sorsogon,07/07/06,Juana,Villegas,Esquivel,Filipino,Muslim,Teacher,Quezon City,Metro Manila,Jovito,Clarivel,Ramos,Filipino,Roman Catholic,Farmer,,,Tabaco,Albay,1003,Rodrigo,Molina,Ramos,M,Tabaco,Albay,01/03/27,Isabel,Portacio,Molina,Filipino,Roman Catholic,Midwife,Quezon City,Metro Manila,Juan Miguel,Esquivel,Ramos,Filipino,Roman Catholic,Farmer,06/03/26,"Quezon City, Metro Manila",Fr. Ramon M. OropezaLegaspi City,Albay,1004,Rebecca,Molina,Ramos,F,Legaspi City,Albay,03/03/29,Isabel,Portacio,Molina,Filipino,Roman Catholic,Engineer,Daet,Camarines Norte,Juan Miguel,Esquivel,Ramos,Filipino,Roman Catholic,Farmer,06/03/26,"Quezon City, Metro Manila",Fr. Ramon M. OropezaLegaspi City,Albay,1005,Maricris,Molina,Ramos,F,Legaspi City,Albay,05/11/30,Isabel,Portacio,Molina,Filipino,Roman Catholic,Pilot,Ligao City,Albay,Juan Miguel,Esquivel,Ramos,Filipino,Roman Catholic,Farmer,06/03/26,"Quezon City, Metro Manila",Fr. Ramon M. OropezaLegaspi City,Albay,1006,Wendy,Lopez,Lee,F,Legaspi City,Albay,06/10/06,Windy,Lee,Lopez,Chinese,Roman Catholic,Teacher,Masbate City,Masbate,Bernardino,Vasquez,Lee,Chinese,Roman Catholic,Engineer,,,Legaspi City,Albay,1007,Jack,Lee,Ramos,M,Legaspi City,Albay,02/02/27,Wendy,Lopez,Lee,Filipino,Roman Catholic,Housewife,Quezon City,Metro Manila,Juan Miguel,Esquivel,Ramos,Filipino,Roman Catholic,Engineer,,,Legaspi City,Albay,1008,Jinky,Lee,Ramos,F,Legaspi City,Albay,08/05/30,Wendy,Lopez,Lee,Filipino,Roman Catholic,Housewife,Tayabas,Quezon,Juan Miguel,Esquivel,Ramos,Filipino,Roman Catholic,Engineer,,,Legaspi City,Albay,1010,Pepito,Solaiman,Lozana,M,Legaspi City,Albay,12/12/10,Norma,Uy,Solaiman,Filipino,Roman Catholic,Housewife,San Pedro,Laguna,Robin,White,Lozana,Filipino,Roman Catholic,Engineer,,,Naga City,Camarines Sur,1011,Nenita,Filomeno,Austria,F,Naga City,Camarines Sur,02/05/22,Pinky,Antonio,Filomeno,Filipino,Roman Catholic,Housewife,San Pedro,Laguna,Mar,San Juan,Austria,Filipino,Roman Catholic,Engineer,,,Mandaluyong City,Metro Manila,1012,John,Filomeno,Austria,M,Mandaluyong City,Metro Manila,05/05/38,Nenita,Filomeno,Austria,Filipino,Muslim,Housewife,Quezon City,Metro Manila,Pepito,Solaiman,Lozana,Filipino,Protestant,Factory Worker,09/11/39,"Taguig City, Metro Manila",Pastor Alex J. HayPasig City,Metro Manila,1013,Marivic,Austria,Lozana,F,Pasig City,Metro Manila,04/11/40,Nenita,Filomeno,Austria,Filipino,Roman Catholic,Housewife,Binan,Laguna,Pepito,Solaiman,Lozana,Filipino,Roman Catholic,Factory Worker,,,Pasig City,Metro Manila,1015,Renante,Agirangan,Paez,M,Pasig City,Metro Manila,11/02/10,Epifania,Restituto,Agirangan,Filipino,Roman Catholic,Factory Worker,Tayabas,Quezon,Rodrigo,Jedegwe,Paez,Filipino,Roman Catholic,Factory Worker,,,Pasig City,Metro Manila,1016,Lolita,Samonte,Martin,F,Pasig City,Metro Manila,01/01/05,Criselda,Abante,Samonte,Filipino,Roman Catholic,Factory Worker,Binan,Laguna,Gerald,Laladap,Martin,Filipino,Roman Catholic,Factory Worker,,,Pasig City,Metro Manila,1017,Mercedez,Martin,Paez,F,Pasig City,Metro Manila,06/04/29,Lolita,Samonte,Martin,Filipino,Roman Catholic,Factory Worker,Quezon City,Metro Manila,Renante,Agirangan,Paez,Filipino,Roman Catholic,Factory Worker,06/14/1928,"Naga City, Camarines Sur",Fr. Luiz M. BenitezOcampo,Camarines Sur,1018,Edilberto,Martin,Paez,M,Ocampo,Camarines Sur,07/11/30,Lolita,Samonte,Martin,Filipino,Muslim,Factory Worker,Quezon City,Metro Manila,Renante,Agirangan,Paez,Filipino,Protestant,Medical Doctor,06/14/1928,"Naga City, Camarines Sur",Fr. Luiz M. BenitezBato,Camarines Sur,1019,Connie,Martin,Paez,F,Bato,Camarines Sur,09/08/31,Lolita,Samonte,Martin,Filipino,Roman Catholic,Factory Worker,Tayabas,Quezon,Renante,Agirangan,Paez,Filipino,Roman Catholic,Fisherman,06/14/1928,"Naga City, Camarines Sur",Fr. Luiz M. BenitezIriga City,Camarines Sur,1020,Minnette,Martin,Paez,F,Iriga City,Camarines Sur,10/10/32,Lolita,Samonte,Martin,Filipino,Roman Catholic,Factory Worker,Binan,Laguna,Renante,Agirangan,Paez,Filipino,Roman Catholic,Medical Doctor,06/14/1928,"Naga City, Camarines Sur",Fr. Luiz M. BenitezIriga City,Camarines Sur,1021,Sonny,Martin,Paez,M,Iriga City,Camarines Sur,10/10/32,Lolita,Samonte,Martin,Filipino,Roman Catholic,Lawyer,San Pedro,Laguna,Renante,Agirangan,Paez,Filipino,Roman Catholic,Medical Doctor,06/14/1928,"Naga City, Camarines Sur",Fr. Luiz M. BenitezIriga City,Camarines Sur,1023,Bernardo,Clemente,Solis,M,Iriga City,Camarines Sur,10/22/1910,Grace,Ticson,Clemente,Filipino,Roman Catholic,Medical Doctor,Daet,Camarines Norte,Rod,Miguran,Solis,Filipino,Roman Catholic,Medical Doctor,,,Iriga City,Camarines Sur,1024,Fe,Paez,Solis,F,Iriga City,Camarines Sur,11/11/50,Mercedez,Martin,Paez,Filipino,Roman Catholic,Medical Doctor,Tayabas,Quezon,Bernardo,Clemente,Solis,Filipino,Roman Catholic,Lawyer,01/11/48,"Pasig City, Metro Manila",Roger X. Dela FuenteIriga City,Camarines Sur,1025,Mae,Paez,Solis,F,Iriga City,Camarines Sur,12/12/51,Mercedez,Martin,Paez,Filipino,Roman Catholic,Medical Doctor,Daet,Camarines Norte,Bernardo,Clemente,Solis,Filipino,Roman Catholic,Lawyer,01/11/48,"Pasig City, Metro Manila",Roger X. Dela FuenteIriga City,Camarines Sur,1026,Aida,Paez,Solis,F,Iriga City,Camarines Sur,09/23/1953,Mercedez,Martin,Paez,Filipino,Roman Catholic,Lawyer,Ligao City,Albay,Bernardo,Clemente,Solis,Filipino,Roman Catholic,Lawyer,01/11/48,"Pasig City, Metro Manila",Roger X. Dela FuenteNaga City,Camarines Sur,1027,Lorna,Paez,Solis,F,Naga City,Camarines Sur,09/27/1955,Mercedez,Martin,Paez,Filipino,Roman Catholic,Lawyer,Ligao City,Albay,Bernardo,Clemente,Solis,Filipino,Roman Catholic,Lawyer,01/11/48,"Pasig City, Metro Manila",Roger X. Dela FuenteNaga City,Camarines Sur,1029,Jose,Madrigal,Pineda,M,Naga City,Camarines Sur,03/23/1920,Lotis,Ponciano,Madrigal,Filipino,Muslim,Lawyer,Tayabas,Quezon,Gavin,Anakleto,Pineda,Filipino,Muslim,Fisherman,,,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
xquery version "1.0-ml";
2+
3+
module namespace plugin = "http://marklogic.com/data-hub/plugins";
4+
5+
declare option xdmp:mapping "false";
6+
7+
(:~
8+
: Collect IDs plugin
9+
:
10+
: @param $options - a map containing options. Options are sent from Java
11+
:
12+
: @return - a sequence of ids or uris
13+
:)
14+
declare function plugin:collect(
15+
$options as map:map) as xs:string*
16+
{
17+
cts:uris((), (), cts:true-query())
18+
};
19+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
xquery version "1.0-ml";
2+
3+
module namespace plugin = "http://marklogic.com/data-hub/plugins";
4+
5+
declare namespace envelope = "http://marklogic.com/data-hub/envelope";
6+
7+
declare option xdmp:mapping "false";
8+
9+
(:~
10+
: Create Content Plugin
11+
:
12+
: @param $id - the identifier returned by the collector
13+
: @param $options - a map containing options. Options are sent from Java
14+
:
15+
: @return - your transformed content
16+
:)
17+
declare function plugin:create-content(
18+
$id as xs:string,
19+
$options as map:map) as node()?
20+
{
21+
let $doc := fn:doc($id)
22+
return
23+
if ($doc/envelope:envelope) then
24+
$doc/envelope:envelope/envelope:content/node()
25+
else if ($doc/content) then
26+
$doc/content
27+
else
28+
$doc
29+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
xquery version "1.0-ml";
2+
3+
module namespace plugin = "http://marklogic.com/data-hub/plugins";
4+
5+
declare namespace envelope = "http://marklogic.com/data-hub/envelope";
6+
7+
declare option xdmp:mapping "false";
8+
9+
(:~
10+
: Create Headers Plugin
11+
:
12+
: @param $id - the identifier returned by the collector
13+
: @param $content - the output of your content plugin
14+
: @param $options - a map containing options. Options are sent from Java
15+
:
16+
: @return - zero or more header nodes
17+
:)
18+
declare function plugin:create-headers(
19+
$id as xs:string,
20+
$content as node()?,
21+
$options as map:map) as node()*
22+
{
23+
()
24+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" ?>
2+
<!--This file is autogenerated. Please don't edit.-->
3+
<flow xmlns="http://marklogic.com/data-hub">
4+
<complexity>simple</complexity>
5+
<data-format>application/xml</data-format>
6+
<plugins></plugins>
7+
</flow>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
xquery version "1.0-ml";
2+
3+
module namespace plugin = "http://marklogic.com/data-hub/plugins";
4+
5+
declare namespace envelope = "http://marklogic.com/data-hub/envelope";
6+
7+
declare option xdmp:mapping "false";
8+
9+
(:~
10+
: Create Triples Plugin
11+
:
12+
: @param $id - the identifier returned by the collector
13+
: @param $content - the output of your content plugin
14+
: @param $headers - the output of your headers plugin
15+
: @param $options - a map containing options. Options are sent from Java
16+
:
17+
: @return - zero or more triples
18+
:)
19+
declare function plugin:create-triples(
20+
$id as xs:string,
21+
$content as node()?,
22+
$headers as node()*,
23+
$options as map:map) as sem:triple*
24+
{
25+
()
26+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
xquery version "1.0-ml";
2+
3+
module namespace plugin = "http://marklogic.com/data-hub/plugins";
4+
5+
declare option xdmp:mapping "false";
6+
7+
(:~
8+
: Writer Plugin
9+
:
10+
: @param $id - the identifier returned by the collector
11+
: @param $envelope - the final envelope
12+
: @param $options - a map containing options. Options are sent from Java
13+
:
14+
: @return - nothing
15+
:)
16+
declare function plugin:write(
17+
$id as xs:string,
18+
$envelope as node(),
19+
$options as map:map) as empty-sequence()
20+
{
21+
xdmp:document-insert($id, $envelope)
22+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<xsl:stylesheet version="2.0"
3+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions"
4+
xmlns:xdmp="http://marklogic.com/xdmp">
5+
6+
<xsl:template match="/">
7+
<xsl:apply-templates select="root" />
8+
</xsl:template>
9+
10+
<xsl:template match="root">
11+
<birth-certificate>
12+
<mother>
13+
<maiden-name>
14+
<firstname><xsl:value-of select="bc-mother-mn-firstname"/></firstname>
15+
<middlename><xsl:value-of select="bc-mother-mn-middlename"/></middlename>
16+
<lastname><xsl:value-of select="bc-mother-mn-lastname"/></lastname>
17+
</maiden-name>
18+
<citizenship><xsl:value-of select="bc-mother-citizenship"/></citizenship>
19+
<religion><xsl:value-of select="bc-mother-religion"/></religion>
20+
<occupation><xsl:value-of select="bc-mother-occupation"/></occupation>
21+
<residence>
22+
<city-or-municipality>
23+
<xsl:value-of select="bc-mother-residence-city-or-municipality"/>
24+
</city-or-municipality>
25+
<province>
26+
<xsl:value-of select="bc-mother-residence-province"/>
27+
</province>
28+
</residence>
29+
</mother>
30+
<father>
31+
<firstname><xsl:value-of select="bc-father-firstname"/></firstname>
32+
<middlename><xsl:value-of select="bc-father-middlename"/></middlename>
33+
<lastname><xsl:value-of select="bc-father-lastname"/></lastname>
34+
<citizenship><xsl:value-of select="bc-father-citizenship"/></citizenship>
35+
<religion><xsl:value-of select="bc-father-religion"/></religion>
36+
<occupation><xsl:value-of select="bc-father-occupation"/></occupation>
37+
</father>
38+
<marraige-of-parents>
39+
<date><xsl:value-of select="bc-mop-date"/></date>
40+
<place><xsl:value-of select="bc-mop-place"/></place>
41+
</marraige-of-parents>
42+
</birth-certificate>
43+
</xsl:template>
44+
</xsl:stylesheet>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
xquery version "1.0-ml";
2+
3+
module namespace plugin = "http://marklogic.com/data-hub/plugins";
4+
5+
declare namespace envelope = "http://marklogic.com/data-hub/envelope";
6+
7+
declare option xdmp:mapping "false";
8+
9+
(:~
10+
: Create Content Plugin
11+
:
12+
: @param $id - the identifier returned by the collector
13+
: @param $raw-content - the raw content being loaded.
14+
: @param $options - a map containing options. Options are sent from Java
15+
:
16+
: @return - your transformed content
17+
:)
18+
declare function plugin:create-content(
19+
$id as xs:string,
20+
$raw-content as node()?,
21+
$options as map:map) as node()?
22+
{
23+
(: $raw-content :)
24+
xdmp:xslt-invoke("content-template.xsl", $raw-content)
25+
};
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<xsl:stylesheet version="2.0"
4+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions"
5+
xmlns:xdmp="http://marklogic.com/xdmp">
6+
7+
<xsl:template match="/">
8+
<xsl:apply-templates select="root" />
9+
</xsl:template>
10+
11+
12+
<xsl:template match="root">
13+
<birth-certificate>
14+
<firstname>
15+
<xsl:value-of select="bc-child-firstname" />
16+
</firstname>
17+
<middlename>
18+
<xsl:value-of select="bc-child-middlename" />
19+
</middlename>
20+
<lastname>
21+
<xsl:value-of select="bc-child-lastname" />
22+
</lastname>
23+
<gender>
24+
<xsl:value-of select="bc-child-sex" />
25+
</gender>
26+
<dob>
27+
<xsl:value-of select="bc-child-dob" />
28+
</dob>
29+
<birth-place>
30+
<city-or-municipality>
31+
<xsl:value-of select="bc-child-bp-city-or-municipality" />
32+
</city-or-municipality>
33+
<province>
34+
<xsl:value-of select="bc-child-bp-province" />
35+
</province>
36+
</birth-place>
37+
<attending-physician>
38+
<xsl:value-of select="bc-attendant" />
39+
</attending-physician>
40+
<registry>
41+
<registry-number>
42+
<xsl:value-of select="bc-registry-number" />
43+
</registry-number>
44+
<city-or-municipality>
45+
<xsl:value-of select="bc-city-or-municipality" />
46+
</city-or-municipality>
47+
<province>
48+
<xsl:value-of select="bc-province" />
49+
</province>
50+
</registry>
51+
</birth-certificate>
52+
</xsl:template>
53+
54+
</xsl:stylesheet>

0 commit comments

Comments
 (0)