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
0 parents
commit c918dbc
Showing
6 changed files
with
376 additions
and
0 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 @@ | ||
env/ |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,63 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Quill Editor Demo</title> | ||
<!-- Include Quill stylesheet --> | ||
<link href="https://cdn.jsdelivr.net/npm/quill@2.0.0-rc.2/dist/quill.snow.css" rel="stylesheet" /> | ||
|
||
</head> | ||
<body> | ||
|
||
<!-- Create the editor container --> | ||
<div id="editor"> | ||
<p>Hello World!</p> | ||
<p>Some initial <strong>bold</strong> text</p> | ||
<p><br /></p> | ||
</div> | ||
|
||
<!-- Include the Quill library --> | ||
<script src="https://cdn.jsdelivr.net/npm/quill@2.0.0-rc.2/dist/quill.js"></script> | ||
|
||
<!-- Initialize Quill editor --> | ||
<script> | ||
const quill = new Quill('#editor', { | ||
theme: 'snow' | ||
}); | ||
var jsonData = [ | ||
{ id: 1, text: 'Option 1' }, | ||
{ id: 2, text: 'Option 2' }, | ||
{ id: 3, text: 'Option 3' } | ||
]; | ||
|
||
// Define custom select handler | ||
Quill.register('modules/custom-select', function(quill, options) { | ||
var container = document.createElement('select'); | ||
options.forEach(function(option) { | ||
var optionElement = document.createElement('option'); | ||
optionElement.setAttribute('value', option.id); | ||
optionElement.textContent = option.text; | ||
container.appendChild(optionElement); | ||
}); | ||
container.onchange = function() { | ||
var value = container.value; | ||
var selection = quill.getSelection(); | ||
quill.insertText(selection.index, container.options[container.selectedIndex].text); | ||
}; | ||
this.container = container; | ||
quill.container.parentNode.querySelector('.ql-custom-select').appendChild(container); | ||
}); | ||
|
||
// Add custom select handler to Quill | ||
document.querySelector('.ql-custom-select').addEventListener('change', function() { | ||
var value = this.value; | ||
var selection = quill.getSelection(); | ||
quill.insertText(selection.index, this.options[this.selectedIndex].text); | ||
}); | ||
</script> | ||
|
||
|
||
</body> | ||
</html> | ||
|
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,2 @@ | ||
bluebell | ||
muzzle |
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,75 @@ | ||
import muzzle | ||
import xml.etree.ElementTree as ET | ||
import json | ||
|
||
def extract_elements_with_attribute(root, attribute_name): | ||
# Initialize list to store elements | ||
elements_with_attribute = [] | ||
|
||
# Traverse XML and extract elements with the specified attribute | ||
def traverse(element): | ||
if attribute_name in element.attrib: | ||
elements_with_attribute.append(element) | ||
for child in element: | ||
traverse(child) | ||
|
||
traverse(root) | ||
|
||
return elements_with_attribute | ||
|
||
# Beispiel XML | ||
xml_string = """ | ||
<root> | ||
<element1 eID="1"> | ||
<subelement1>eID 1</subelement1> | ||
</element1> | ||
<element2> | ||
<subelement2>eID 2</subelement2> | ||
</element2> | ||
<element3 eID="3"> | ||
<subelement3>eID 3</subelement3> | ||
</element3> | ||
</root> | ||
""" | ||
|
||
with open("fedlex.xml") as f: | ||
xml_content = f.read().encode() | ||
|
||
|
||
namespaces = { | ||
"akn": "http://docs.oasis-open.org/legaldocml/ns/akn/3.0", | ||
"xsd": "http://www.w3.org/2001/XMLSchema", | ||
} | ||
xmlparser = muzzle.XMLParser(namespaces) | ||
xml = xmlparser.parse(xml_content) | ||
|
||
|
||
uri_base = xmlparser.find(xml, './/akn:FRBRuri') | ||
uri_value = uri_base.attrib['value'] | ||
print(f"URI: {uri_value}") | ||
|
||
# Attribute Name | ||
attribute_name = "eId" | ||
|
||
# Extrahiere Elemente mit dem Attribut "eID" | ||
elements = extract_elements_with_attribute(xml, attribute_name) | ||
|
||
|
||
# Ausgabe der extrahierten Elemente | ||
json_content = {} | ||
for element in elements: | ||
for par in xmlparser.findall(element, './akn:content/akn:p'): | ||
content_id = f"{uri_value}/{element.attrib['eId']}" | ||
print(f"{content_id}") | ||
print(par.text) | ||
print('') | ||
json_content[content_id] = par.text | ||
|
||
with open("content.json", "w") as fw: | ||
fw.write(json.dumps(json_content, indent=4)) | ||
|
||
|
||
|
||
|
||
|
||
#print(xml.find('./FRBRuri')) |