Consider XSLT, the special purpose language designed to transform XML files like flattening them at certain sections. Python’s third-party module, lxml, can run XSLT 1.0 scripts and XPath 1.0 expressions.
Specifically, XSLT can handle your XPath extractions. Then, from the single transformed result tree, build the needed three data frames. For well-formedness, below assumes the following root and data structure:
<integration-outbound:IntegrationEntity xmlns:integration-outbound="http://example.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ...same content... </integration-outbound:IntegrationEntity>
XSLT (save as .xsl, a special .xml file)
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:integration-outbound="http://example.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="integration-outbound:IntegrationEntity"> <data> <xsl:apply-templates select="integrationEntityHeader/descendant::attachment"/> <xsl:apply-templates select="integrationEntityDetails/descendant::dataProcessingInfo"/> <xsl:apply-templates select="integrationEntityDetails/descendant::forms/descendant::field"/> </data> </xsl:template> <xsl:template match="attachment"> <integrationEntityHeader> <xsl:copy-of select="ancestor::integrationEntityHeader/*[name()!='attachments']"/> <xsl:copy-of select="*"/> </integrationEntityHeader> </xsl:template> <xsl:template match="dataProcessingInfo"> <integrationEntityDetailsControlBlock> <xsl:copy-of select="ancestor::integration-outbound:IntegrationEntity/integrationEntityHeader/*[position() <= 2]"/> <requestId><xsl:value-of select="ancestor::supplier/requestId"/></requestId> <supplier_id><xsl:value-of select="ancestor::supplier/id"/></supplier_id> <xsl:copy-of select="*"/> </integrationEntityDetailsControlBlock> </xsl:template> <xsl:template match="field"> <integrationEntityDetailsForms> <form_id><xsl:value-of select="ancestor::form/id"/></form_id> <xsl:copy-of select="ancestor::record/*[name()!='fields']"/> <SupplierFormRecordFieldId><xsl:value-of select="id"/></SupplierFormRecordFieldId> <SupplierFormRecordFieldValue><xsl:value-of select="id"/></SupplierFormRecordFieldValue> <xsl:copy-of select="ancestor::integration-outbound:IntegrationEntity/integrationEntityHeader/*[position() <= 2]"/> <requestId><xsl:value-of select="ancestor::supplier/requestId"/></requestId> <supplier_id><xsl:value-of select="ancestor::supplier/id"/></supplier_id> </integrationEntityDetailsForms> </xsl:template> </xsl:stylesheet>
Python
import lxml.etree as et import pandas as pd # LOAD XML AND XSL doc = et.parse('Input.xml') style = et.parse('Script.xsl') # INITIALIZE AND RUN TRANSFORMATION transformer = et.XSLT(style) flat_doc = transformer(doc) # BUILD THREE DATA FRAMES df_header = pd.DataFrame([{i.tag:i.text for i in el} for el in flat_doc.xpath('integrationEntityHeader')]) df_detailsControlBlock = pd.DataFrame([{i.tag:i.text for i in el} for el in flat_doc.xpath('integrationEntityDetailsControlBlock')]) df_detailsForms = pd.DataFrame([{i.tag:i.text for i in el} for el in flat_doc.xpath('integrationEntityDetailsForms')])
Important to note with elementFormDefault is that it applies to locally defined elements, typically named elements inside a complexType block, as opposed to global elements defined on the top-level of the schema. With elementFormDefault=”qualified” you can address local elements in the schema from within the xml document using the schema’s target namespace as the document’s default namespace.
In practice, use elementFormDefault=”qualified” to be able to declare elements in nested blocks, otherwise you’ll have to declare all elements on the top level and refer to them in the schema in nested elements using the ref attribute, resulting in a much less compact schema.
This bit in the XML Schema Primer talks about it: http://www.w3.org/TR/xmlschema-0/#NS
Presuming that "max_questions" is some kind of translation issue around "max_connections", you probably need to stop initializing a new database connection for every query and instead reuse a connection.
Short answer, yes, sort of. You can use Objective-C++, which you can read about at Apple Developer Connection.
If you know C++ already, learning Objective-C would be pretty simple, if you decided to give that a try. More info on that topic is at the ADC as well.
When you do a
require()
you can either require the whole export object or use destructuring.So in MAIN.JS you would do something like:
{firstResult, secondResult} = require(‘./SQLQUERY.js’)
And then those two values would be available in the MAIN.js code. At least that’s how I do it when I need to import specific values from the export, not the entire object. I’m not an expert either so I don’t know if a simple
require('./SQLQUERY')
would make these objects available.
It can be done using
sc = spark_session.sparkContext sc.setJobGroup(...) # In a separate thread: sc.cancelJobGroup(...)
There is a full example in PySpark API documentation
for i in "apple": if i == "l": continue print(i)
What you are looking for is the
continue
statement, which exits the loop iteration and moves to the next one, in a way you can see it as the return statement for a loop.
break
will exit the loop completely (stop iterating).
One approach you could do is to entend each array m1, m2, …. by one value. Then replace that extra value and ‘-1’ by the (length-1) of next array m2, m3, … respectively.
But, in the last array, change ‘-1’ to ‘no match’ (or any other value you prefer), and append the same value.
m1 = [-1, 0, 2, -1, 3, 8, 7, -1, 9, 5] m2 = [-1, 0, 2, 6, 3, 8, 7, -1, 9, 5] m_list = [m1, m2] for i in range(len(m_list)-1): m_list[i] = [len(m_list[i+1]) if x==-1 else x for x in m_list[i]] m_list[i].append(len(m_list[i+1])) m_list[len(m_list)-1] = ['no match' if x==-1 else x for x in m_list[len(m_list)-1]] m_list[len(m_list)-1].append('no match') m1, m2 = m_list
Now if you run
m2[m1[7]]
, your output will be'no match'
.Note : The m1, m2, …. you will get will have one extra length. So if you are using it somewhere else, be careful for any errors.
Multiple currently working only with input type="email" and only in Chrome and Opera
Reference: multiple selections with datalist
I think the dompdf parser cant handle js, and if it does, it doesnt know the answers user have chosen (you can verify this by outputting what you use to feed the domPdf). So better would be just send answers to php script and let it generate html of the pdf which you can then send to dompdf, for generating pdf.