Commit 53bc29a8 authored by mouadh's avatar mouadh

xmlwitch

parent b2b55015
......@@ -2,6 +2,8 @@
from __future__ import absolute_import, division, print_function
import HTMLParser
import xmlwitch
import os
from datetime import datetime
......@@ -161,14 +163,20 @@ class XmlaProviderService(ServiceBase):
# check if command contains a query
xml = xmlwitch.Builder()
# xml.return return reserved of course
with xml['return']:
xml.root(xmlns="urn:schemas-microsoft-com:xml-analysis:empty")
return """
<return>
{0}
</return>
""".format(str(xml))
return str(xml)
# xml = xmlwitch.Builder()
# # xml.return return reserved of course
# xml.root(xmlns="urn:schemas-microsoft-com:xml-analysis:empty")
#
# return """
# <return>
# {0}
# </return>
# """.format(str(xml))
else:
XmlaProviderService.discover_tools.change_catalogue(
request.Properties.PropertyList.Catalog)
......@@ -194,46 +202,79 @@ class XmlaProviderService(ServiceBase):
#
# xml.CellData(xmla_tools.generate_cell_data(df))
return etree.fromstring("""
<return>
<root xmlns="urn:schemas-microsoft-com:xml-analysis:mddataset"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
{0}
<OlapInfo>
<CubeInfo>
<Cube>
<CubeName>Sales</CubeName>
<LastDataUpdate
xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">{7}</LastDataUpdate>
<LastSchemaUpdate
xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">{7}</LastSchemaUpdate>
</Cube>
</CubeInfo>
<AxesInfo>
{1}
{2}
</AxesInfo>
{3}
</OlapInfo>
<Axes>
{4}
{5}
</Axes>
<CellData>
{6}
</CellData>
</root>
</return>
""".format(execute_xsd,
xmla_tools.generate_axes_info(df),
xmla_tools.generate_axes_info_slicer(df),
xmla_tools.generate_cell_info(),
xmla_tools.generate_xs0(df),
xmla_tools.generate_slicer_axis(df),
xmla_tools.generate_cell_data(df),
datetime.now().strftime('%Y-%m-%dT%H:%M:%S')).replace(
'&', '&amp;'))
# todo to check
xml = xmlwitch.Builder()
with xml['return']:
with xml.root(
execute_xsd,
xmlns="urn:schemas-microsoft-com:xml-analysis:mddataset",
**{
'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema',
'xmlns:xsi':
'http://www.w3.org/2001/XMLSchema-instance'
}):
with xml.OlapInfo(xmla_tools.generate_cell_info()):
with xml.CubeInfo:
with xml.Cube:
xml.CubeName('Sales')
xml.LastDataUpdate(datetime.now().strftime('%Y-%m-%dT%H:%M:%S'),
xmlns="http://schemas.microsoft.com/analysisservices/2003/engine")
xml.LastSchemaUpdate(datetime.now().strftime('%Y-%m-%dT%H:%M:%S'),
xmlns="http://schemas.microsoft.com/analysisservices/2003/engine")
xml.AxesInfo(xmla_tools.generate_axes_info(df),
xmla_tools.generate_axes_info_slicer(df))
xml.Axes(xmla_tools.generate_xs0(df),
xmla_tools.generate_slicer_axis(df))
xml.CellData(xmla_tools.generate_cell_data(df))
html_parser = HTMLParser.HTMLParser()
xml = html_parser.unescape(str(xml)).replace('&', '&amp;')
return xml
# return etree.fromstring("""
# <return>
# <root xmlns="urn:schemas-microsoft-com:xml-analysis:mddataset"
# xmlns:xsd="http://www.w3.org/2001/XMLSchema"
# xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
# {0}
# <OlapInfo>
# <CubeInfo>
# <Cube>
# <CubeName>Sales</CubeName>
# <LastDataUpdate
# xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">{7}</LastDataUpdate>
# <LastSchemaUpdate
# xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">{7}</LastSchemaUpdate>
# </Cube>
# </CubeInfo>
# <AxesInfo>
# {1}
# {2}
# </AxesInfo>
# {3}
# </OlapInfo>
# <Axes>
# {4}
# {5}
# </Axes>
# <CellData>
# {6}
# </CellData>
# </root>
# </return>
# """.format(execute_xsd,
# xmla_tools.generate_axes_info(df),
# xmla_tools.generate_axes_info_slicer(df),
# xmla_tools.generate_cell_info(),
# xmla_tools.generate_xs0(df),
# xmla_tools.generate_slicer_axis(df),
# xmla_tools.generate_cell_data(df),
# datetime.now().strftime('%Y-%m-%dT%H:%M:%S')).replace(
# '&', '&amp;'))
# Problem:
# An XML parser returns the error “xmlParseEntityRef: noname”
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment