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


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

2017-04-19 Thread Michael Kay
Sorry, but the XPath/XQuery data model has no way of representing an element 
node whose name has an undeclared prefix. XPath and XQuery work only with 
namespace-well-formed XML.

If you really need this badly enough, you could either

(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

(b) customize the Saxon serializer. Subclass net.sf.saxon.serialize.XMLEmitter 
to override the namespace() method, subclass net.sf.saxon.lib.SerializerFactory 
overriding the newXMLEmitter() method to instantiate your XMLEmitter subclass, 
and nominate your subclassed SerializerFactory using 
Configuration.setSerializerFactory() - not actually that difficult if you're 
comfortable with Java programming.

Michael Kay
Saxonica

> On 19 Apr 2017, at 11:10, xqu...@docbook-autor.de wrote:
> 
> 
> 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


___
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 Michael Kay
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?

Michael Kay
Saxonica

> On 19 Apr 2017, at 09:51, xqu...@docbook-autor.de wrote:
> 
> 
> 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


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