[xquery-talk] Omit namespace attributes in output file

2017-04-19 Thread xquery

 Hi,

I’m transforming some DocBook data into an XML file using XQuery. The
transformation works perfectly so far.

My problem is, that I have to use some confluence namespace tags like
 in the XML output file.

So I have to declare the respective namespace at the beginning of my
XQuery file:

###
xquery version "1.0" encoding "utf-8";

declare namespace db="http://docbook.org/ns/docbook";;
declare namespace saxon="http://saxon.sf.net/";;
declare namespace ac="https://www.atlassian.com/schema/confluence/6/ac";;

declare option saxon:output "version=1.0";
declare option saxon:output "omit-xml-declaration=yes";
declare option saxon:output "indent=yes";
###

Because of the namespace declaration for "ac" at the beginning the
transformation results in this:

###
https://www.atlassian.com/schema/confluence/6/ac";
ac:name="warning"/>
###

Without this declaration the transformation stops with an error message
that a declaration for namespace “ac” is missing.

Is it possible to omit the xmlns:ac attribute somehow?

Thanks in advance!

Regards
Michael
___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk

Re: [xquery-talk] Omit namespace attributes in output file

2017-04-19 Thread xquery

 Hi,

> XQuery output has to be well-formed (and namespace-well-formed) XML,
> so you can't output an element name like  unless the
> "ac" prefix is declared and bound to a namespace URI. Why would you
> want to? Does Confluence really use non-namespace-aware XML?

my xml output file will be some Confluence wiki page saved as file on
the server so Confluence will load it on its next start-up.

Inside Clonfluence the namespace "ac" surely will be well-formed but
that is part of the higher-level "frame" where my xml file is loaded into.

BTW: The Confluence Storage Format for wiki pages uses all its
namespaces without namespace declaration inside the respective wiki page
itself. That seems to be part of the Confluence framework.

It is correct to demand the declaration of namespaces. I do not question
that. But with

declare option saxon:output "omit-xml-declaration=yes";

I can omit the xml declaration at the beginning of the xml output file.
I need some parameter/option to omit every namespace declaration.

Kind of:

declare option saxon:output "omit-all-ns-declaration=yes";

So I declare the following namespace as I do it now:

declare namespace ac="https://www.atlassian.com/schema/confluence/6/ac";;

If not there will be an error message due to a missing namespace
declaration.

But the option above would leave the Confluence namespaced tags in my
output file as they are:



Is there a possibility to achieve this with XQuery or Saxon?

 Best regards from Germany
  Michael
___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk


Re: [xquery-talk] Omit namespace attributes in output file

2017-04-19 Thread xquery

 Hi Michael,

> (a) post-process the serialized XML to strip off the namespace declarations 
> (e.g. with a non-XML tool such as sed or awk), or
ok, first I have to check, whether Confluence is able to deal with
namespace declarations inside a wiki page anyway.

If yes anything is fine.

If not the post-processing should do it. I'm starting the transformation
with a script file so it should be easy to delete some text in the xml
output file by script too.

Fumbling around with standard sources is never a good idea (or at least
should be the very last choice IMHO).

Thanks for your quick help!

 Best regards from Germany
  Michael
___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk


[xquery-talk] SQL to XML with XQuery?

2017-08-09 Thread xquery

 Hi,

I know that XQuery is typically used for transforming XML into other
text file formats.

But is it possible to use XQuery for the other way round?

I want to transform a very simple SQL Create Table statement into XML.


SQL
===

CREATE TABLE mytable1

(
  FIELD1xxx;
  FIELD2xxx;
  FIELD3xxx;
);

COMMENT ON COLUMN mytable1.FIELD1 'Description1';
COMMENT ON COLUMN mytable1.FIELD2 'Description2';

CREATE TABLE mytable2

(
  FIELD1xxx;
  FIELD2xxx;
  FIELD3xxx;
);

COMMENT ON COLUMN mytable2.FIELD1 'Description1';
COMMENT ON COLUMN mytable2.FIELD3 'Description3';


XML
===


  mytable1
  
FIELD1
Description1
  
  
FIELD2
Description2
  
  
FIELD1

  



  mytable2
  
FIELD1
Description1
  
  
FIELD2

  
  
FIELD1
    Description3
  


Can this be done via XQuery? If not which tool could possibly fit my needs?

Best regards
Michael
___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk


Re: [xquery-talk] SQL to XML with XQuery?

2017-08-10 Thread xquery

 Hi Mike and Ghislain,

> Of course, parsing a full language like SQL is best done using the typical 
> approaches (lexer, grammar, etc) as Mike suggests, and is not trivial. But if 
> the subset is really very simple (as simple as your example), known in 
> advance, and if there are no irregularities in newlines, etc, then the above, 
> more ad-hoc approach could work as well quite straightforwardly: a for to 
> iterate on the lines, start tumbling windows at rows that start with "CREATE 
> TABLE", then sub-windows to catch the parentheses and the COMMENTs, and then 
> convert the contents to XML nodes.


yes, the scenario is really that simple.

I get files with round about 40 to 100 CREATE TABLEs each and have to
transform those into XML files (subsequently I have to transform those
XML files into DocBook entity files where XQuery would come into play
anyway).

I tried to import those CREATE TABLEs into MySQL and to export the
resulting database as XML. Unfortunately MySQL only exports to  tag level with the CREATE TABLE state as value:


  CREATE TABLE `mytable1` (
`FIELD1` xxx DEFAULT NULL,
`FIELD2` xxx DEFAULT NULL,
`FIELD3` xxx DEFAULT NULL
)


Maybe I'm missing something with the XML export feature of MySQL.

I'm not an XQuery expert... maybe that export will do already to use
XQuery for generating the DocBook entity file.

Is it possible to take apart tag values with XQuery so that every
'FIELDx' gets its own entry after the transformation?

@Ihe Onwuka: Using DB2 is not an option. I just get those files. Best i
can do is to use MySQL.

Best regards
Michael
___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk


Re: [xquery-talk] SQL to XML with XQuery?

2017-08-10 Thread xquery

 Hi Christian,

> Would you like to parse your SQL (or just DDL) expressions in XQuery
> and execute them in a second step? Do you want to store SQL data in an
> XML database in a leter step, or do you only want to create a schema
> representation of your SQL table definitions in XML, resulting from
> your SQL statements?

yes, a "simple" SQL parsing should do.

> The answer is definitely yes. On a logical level, you can do pretty
> much everything in XQuery, but I assume your use case is much more
> practical?

yes, it is. As I mentioned in my previous response I have to transform
lots of files with 40 to 100 CREATE TABLEs each into DocBook entity files.

Done by hand it's extremely unsatisfying... especially because I'm
dealing with transformation of text into text and not some stream or
crypto data.

The plan is that first of all I will generate a DocBook documentation
out of the SQL data. The next step will be that my customer can fill his
database with all the still missing comments of his database columns out
of the then completed entity file (XML to SQL transformation).

Soweit der Plan... ;-)

Best regards from Aachen
Michael
___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk


Re: [xquery-talk] SQL to XML with XQuery?

2017-08-11 Thread xquery

 Hi Ghislain,

> I got the query below to work on the sample that you gave us. It gives the 
> required input with Zorba and requires XQuery 3.0 (for the windows). It only 
> took a few minutes to write and can probably be improved, but this should 
> give you a starting point.

thanks a lot! I will test it over the weekend and report the results.

Have a nice weekend and best regards
Michael
___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk