Skip to content

Commit 4f83610

Browse files
committed
Merge branch 'OpenWork-NZ-master'
2 parents 42b1e5b + 76d2fcc commit 4f83610

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

ogc/bblocks/known-mimetypes.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ xml:
3434
mimeType: application/xml
3535
aliases:
3636
- application/xml
37+
- text/xml
3738
extensions:
3839
- xml
3940

ogc/bblocks/schemas/transforms.schema.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ $defs:
6969
- json-ld-frame
7070
- jq
7171
- semantic-uplift
72+
- xslt
7273
- description: Other identifiers are also accepted
7374
$ref: '#/$defs/nonEmptyString'
7475

ogc/bblocks/transformers/xslt.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python3
2+
import json
3+
from typing import AnyStr
4+
5+
from ogc.bblocks.models import TransformMetadata, Transformer
6+
from lxml import etree
7+
8+
transform_type = 'xslt'
9+
10+
default_inputs = [
11+
'application/xml',
12+
]
13+
14+
default_outputs = [
15+
'application/xml',
16+
]
17+
18+
class XmlTransformer(Transformer):
19+
20+
def __init__(self):
21+
super().__init__(['xslt'], default_inputs, default_outputs)
22+
23+
def do_transform(self, metadata: TransformMetadata) -> AnyStr | None:
24+
transform = etree.XSLT(etree.XML(metadata.transform_content.encode('utf-8')))
25+
result = transform(etree.XML(metadata.input_data.encode('utf-8')))
26+
return etree.tostring(result, encoding='utf-8', pretty_print=True, xml_declaration=True).decode('utf-8')

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ networkx~=3.1
1313
jq~=1.6
1414
pathvalidate==3.2.0
1515
jsonpointer~=2.4
16+
lxml~=5.0.0
1617

1718
# mkdocs
1819
mkdocs>=1.4.2
@@ -25,4 +26,4 @@ mkdocs-pymdownx-material-extras
2526
mkdocs-section-index
2627
mkdocstrings
2728
mkdocstrings-python
28-
mkdocs-markdownextradata-plugin
29+
mkdocs-markdownextradata-plugin

0 commit comments

Comments
 (0)