Changing element namespace on input

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Changing element namespace on input

Hans Hübner
Hi,

we need to process a large number of large XML documents that have no namespace and that should be in a particular namespace in the result document, retaining their element names.  We know that we can change the name space of an element while writing, but in this particular situation, it would actually be helpful if we could add a namespace URL to all element nodes while reading.  Is this something that Saxon can do directly, or do we need to use a specialized reader written in Java that adds/changes namespaces in elements read before handing them to Saxon?

Thanks,
Hans

--
LambdaWerk GmbH
Oranienburger Straße 87/89
10178 Berlin
Phone: +49 30 555 7335 0
Fax: +49 30 555 7335 99

HRB 169991 B Amtsgericht Charlottenburg
USt-ID: DE301399951
Geschäftsführer:  Hans Hübner




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Changing element namespace on input

Florent Georges-3
Hi Hans,

As a general XSLT solution (Saxon might have something more specialized), I would use a separate stylesheet module with a template rule on "element()", changing the namespace, then applying imports.

You mentioned your input files are large.  If you do not use streaming, that should not change anything.  If you do, it might be challenging to take this approach while staying guaranteed-streamable.

If you already launch Saxon from Java, the easiest remains probably to write your own Source class for presenting Saxon with your (modified) input XML.

Regards,

-- 
Florent Georges
H2O Consulting
http://h2o.consulting/ 


On 29 June 2017 at 13:22, Hans Hübner wrote:
Hi,

we need to process a large number of large XML documents that have no namespace and that should be in a particular namespace in the result document, retaining their element names.  We know that we can change the name space of an element while writing, but in this particular situation, it would actually be helpful if we could add a namespace URL to all element nodes while reading.  Is this something that Saxon can do directly, or do we need to use a specialized reader written in Java that adds/changes namespaces in elements read before handing them to Saxon?

Thanks,
Hans

--
LambdaWerk GmbH
Oranienburger Straße 87/89
10178 Berlin
Phone: +49 30 555 7335 0
Fax: +49 30 555 7335 99

HRB 169991 B Amtsgericht Charlottenburg
USt-ID: DE301399951
Geschäftsführer:  Hans Hübner




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help





------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Changing element namespace on input

Hans Hübner
Thank you, Florent (and Hans-Jürgen, Martin).  We take it that we're going to need to implement a separate input filter and a wrapper for the command line if we want to change the namespace of incoming nodes while reading.  Not a big deal :)

Cheers,
Hans

On Thu, Jun 29, 2017 at 3:24 PM, Florent Georges <[hidden email]> wrote:
Hi Hans,

As a general XSLT solution (Saxon might have something more specialized), I would use a separate stylesheet module with a template rule on "element()", changing the namespace, then applying imports.

You mentioned your input files are large.  If you do not use streaming, that should not change anything.  If you do, it might be challenging to take this approach while staying guaranteed-streamable.

If you already launch Saxon from Java, the easiest remains probably to write your own Source class for presenting Saxon with your (modified) input XML.

Regards,

-- 
Florent Georges
H2O Consulting
http://h2o.consulting/ 


On 29 June 2017 at 13:22, Hans Hübner wrote:
Hi,

we need to process a large number of large XML documents that have no namespace and that should be in a particular namespace in the result document, retaining their element names.  We know that we can change the name space of an element while writing, but in this particular situation, it would actually be helpful if we could add a namespace URL to all element nodes while reading.  Is this something that Saxon can do directly, or do we need to use a specialized reader written in Java that adds/changes namespaces in elements read before handing them to Saxon?

Thanks,
Hans

--
LambdaWerk GmbH
Oranienburger Straße 87/89
10178 Berlin
Phone: +49 30 555 7335 0
Fax: +49 30 555 7335 99

HRB <a href="tel:169991" value="+49169991" target="_blank">169991 B Amtsgericht Charlottenburg
USt-ID: DE301399951
Geschäftsführer:  Hans Hübner




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help





------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help



--
LambdaWerk GmbH
Oranienburger Straße 87/89
10178 Berlin
Phone: +49 30 555 7335 0
Fax: +49 30 555 7335 99

HRB 169991 B Amtsgericht Charlottenburg
USt-ID: DE301399951
Geschäftsführer:  Hans Hübner




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Changing element namespace on input

Michael Kay
In reply to this post by Hans Hübner
There's nothing built-in to achieve this, but it's not difficult to achieve by putting a SAX filter into the pipeline before the transformation - there's an example doing just this in my book XSLT Programmer's Reference (4th edition, p1190-1192). Alternatively the preprocessing step can be done with another XSLT transformation.

Michael Kay
Saxonica

On 29 Jun 2017, at 12:22, Hans Hübner <[hidden email]> wrote:

Hi,

we need to process a large number of large XML documents that have no namespace and that should be in a particular namespace in the result document, retaining their element names.  We know that we can change the name space of an element while writing, but in this particular situation, it would actually be helpful if we could add a namespace URL to all element nodes while reading.  Is this something that Saxon can do directly, or do we need to use a specialized reader written in Java that adds/changes namespaces in elements read before handing them to Saxon?

Thanks,
Hans

--
LambdaWerk GmbH
Oranienburger Straße 87/89
10178 Berlin
Phone: +49 30 555 7335 0
Fax: +49 30 555 7335 99

HRB 169991 B Amtsgericht Charlottenburg
USt-ID: DE301399951
Geschäftsführer:  Hans Hübner



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Loading...