Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Oyvind.Gjesdal
xlsx-xsl
Commits
61651337
Commit
61651337
authored
Jul 21, 2020
by
oyvind Gjesdal
Browse files
tillat zip, prøv unix sti med trippel
parent
2143a72f
Changes
1
Hide whitespace changes
Inline
Side-by-side
xlsx.xsl
View file @
61651337
...
...
@@ -28,11 +28,11 @@
</root>
-->
<xsl:output
indent=
"yes"
method=
"xml"
/>
<xsl:param
name=
"path-restriction"
as=
"xs:string?"
select=
"'
/ok
'"
/>
<xsl:param
name=
"path-restriction"
as=
"xs:string?"
select=
"'
excel
'"
/>
<xsl:param
name=
"path"
select=
"'
../../input/variant
'"
/>
select=
"'
/home/oyvind/repos/datasets/input/dataset-termportalen/input/excel
'"
/>
<xsl:param
name=
"is-folder"
select=
"true()"
as=
"xs:boolean"
/>
<xsl:param
name=
"starting-row"
select=
"
0
"
as=
"xs:integer"
/>
<xsl:param
name=
"starting-row"
select=
"
1
"
as=
"xs:integer"
/>
<xsl:import
href=
"xsl-lib/functions/OOXML/spreadsheetML.xsl"
/>
<xsl:key
name=
"element-name"
match=
"name"
use=
"@r"
/>
...
...
@@ -43,9 +43,11 @@
<xsl:template
name=
"xlsx2xml"
>
<xsl:param
name=
"xlsx-path"
as=
"xs:string"
/>
<xsl:message
select=
"$xlsx-path"
/>
<xsl:variable
name=
"worksheets"
select=
"collection($xlsx-path || '?select=*sheet*xml;recurse=yes')"
as=
"document-node()*"
/>
<xsl:variable
name=
"shared-strings"
select=
"collection($xlsx-path || '?select=*sharedStrings.xml;recurse=yes')"
as=
"document-node()?"
/>
<xsl:variable
name=
"styles"
select=
"collection($xlsx-path || '?select=*styles.xml;recurse=yes')"
as=
"document-node()*"
/>
<xsl:variable
name=
"worksheets"
select=
"collection($xlsx-path || '?select=*sheet*xml' )"
as=
"document-node()+"
/>
<xsl:variable
name=
"shared-strings"
select=
"collection($xlsx-path || '?select=*sharedStrings.xml;recurse=yes')"
as=
"document-node()+"
/>
<xsl:variable
name=
"styles"
select=
"collection($xlsx-path || '?select=*styles.xml;recurse=yes')"
as=
"document-node()+"
/>
<root>
<xsl:for-each
select=
"$worksheets"
>
<!-- construct one element names tables for each workbook sheet, which is tunneled to subcontext-->
...
...
@@ -81,14 +83,15 @@
<xsl:message
select=
"'/', $path,$is-folder"
></xsl:message>
<xsl:choose>
<xsl:when
test=
"$is-folder"
>
<xsl:for-each
select=
"collection($path||'?
select=*xlsx;metadata
=yes')"
>
<xsl:variable
name=
"this.xslx"
select=
"map:get(.,'name')
"
as=
"xs:string"
/>
<xsl:message
select=
"$this.xslx"
/>
<xsl:for-each
select=
"collection($path||'?
matches=(xlsx|zip)$;metadata=yes;recurse
=yes')"
>
<xsl:variable
name=
"this.xslx"
select=
"
replace(
map:get(.,'name')
,'file:/([^/])','file:///$1')"
as=
"xs:string"
/>
<xsl:message
select=
"
string-join(map:keys(.), ' ') ||
$this.xslx"
/>
<xsl:if
test=
"not($is-folder) or not($path-restriction) or contains($this.xslx,$path-restriction)"
>
<xsl:result-document
method=
"xml"
indent=
"yes"
href=
"{replace($this.xslx,'xlsx$','xml','i')}"
>
<xsl:result-document
method=
"xml"
indent=
"yes"
href=
"
../result/
{replace($this.xslx,'
(
xlsx
|zip)
$','xml','i')}"
>
<xsl:call-template
name=
"xlsx2xml"
>
<xsl:with-param
name=
"xlsx-path"
select=
"$this.xslx"
/>
</xsl:call-template>
</xsl:call-template>
</xsl:result-document>
</xsl:if>
</xsl:for-each>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment