problem with serializing part of xml file

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

problem with serializing part of xml file

marc.natale
Hi,

I would like to serialize only a part of a xml file, but I didn't succeed in finding the efficient command line to do so. I have a "instance" xml file, whose root is the tag <form>. I would like to serialize only from form/tag1/tag2...
I thought about 2 possibilities:

1)in a xpl file:
<p:param name="instance" type="input"/>

<p:processor name="oxf:file-serializer">
<p:input name="config">
<config>
<file>instance.xml</file>
<directory>c:/temp</directory>
</config>
</p:input>
<p:input name="data" href="#instance(WHAT TO PUT HERE?)"/>
</p:processor>

I think I should write with xpath, but I do not know which syntax is appropriate here... Maybe with #xpointer, but I did not find its doc in the orbeon website...

2)using an xslt processor
<p:processor name="oxf:xslt">
<p:input name="config" href="my-transformation.xsl"/>
<p:input name="data" href="#instance"/>
<p:output name="data" id="transformation-result"/>
</p:processor>

<p:processor name="oxf:file-serializer">p:processor name="oxf:file-serializer">
<p:input name="config">
<config>
<file>instance.xml </file>
<directory>c:/temp</directory>
</config>
</p:input>
<p:input name="data" href="#transformation-result"/>
</p:processor>

and I wrote this my-transformation.xsl file:

<?xml version="2.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl=" http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema " xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes" ><xsl:template match="/">
<xsl:copy-of select="//tag2" />
</xsl:template>
</xsl:stylesheet>

In this case, it works well if I use <xsl:copy-of select="//tag1" />, but with "tag2", it doesn't work! (the xml file is then empty)
the only difference between the two tags is that tag2 has 2 namespace declared... while tag1 has neither attribute nor xmlns declared...
 
What I want to do is very basic, I'm sure there are many ways to solve the problem, but I have not found it in the archive...
Thank's for helping,
Marc


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: problem with serializing part of xml file

marc.natale
ok,
I've settled the issue after many tests... using the xpointer, and without declaring the good namespace above...
However, has somebody designed something that enables the user to navigate in his drive in order to display the path and the directory where the user will save its xml output?
Marc
 
On 18/08/05, Marc Natale <[hidden email]> wrote:
Hi,

I would like to serialize only a part of a xml file, but I didn't succeed in finding the efficient command line to do so. I have a "instance" xml file, whose root is the tag <form>. I would like to serialize only from form/tag1/tag2...
I thought about 2 possibilities:

1)in a xpl file:
<p:param name="instance" type="input"/>

<p:processor name="oxf:file-serializer">
<p:input name="config">
<config>
<file>instance.xml</file>
<directory>c:/temp</directory>
</config>
</p:input>
<p:input name="data" href="#instance(WHAT TO PUT HERE?)"/>
</p:processor>

I think I should write with xpath, but I do not know which syntax is appropriate here... Maybe with #xpointer, but I did not find its doc in the orbeon website...

2)using an xslt processor
<p:processor name="oxf:xslt">
<p:input name="config" href="my-transformation.xsl"/>
<p:input name="data" href="#instance"/>
<p:output name="data" id="transformation-result"/>
</p:processor>

<p:processor name="oxf:file-serializer">p:processor name="oxf:file-serializer">
<p:input name="config">
<config>
<file>instance.xml </file>
<directory>c:/temp</directory>
</config>
</p:input>
<p:input name="data" href="#transformation-result"/>
</p:processor>

and I wrote this my-transformation.xsl file:

<?xml version="2.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl=" http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs=" http://www.w3.org/2001/XMLSchema " xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xdt=" http://www.w3.org/2005/02/xpath-datatypes" ><xsl:template match="/">
<xsl:copy-of select="//tag2" />
</xsl:template>
</xsl:stylesheet>

In this case, it works well if I use <xsl:copy-of select="//tag1" />, but with "tag2", it doesn't work! (the xml file is then empty)
the only difference between the two tags is that tag2 has 2 namespace declared... while tag1 has neither attribute nor xmlns declared...
 
What I want to do is very basic, I'm sure there are many ways to solve the problem, but I have not found it in the archive...
Thank's for helping,
Marc



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: problem with serializing part of xml file

Erik Bruchez
Administrator
In reply to this post by marc.natale
Marc,

 > I would like to serialize only a part of a xml file, but I didn't
 > succeed in finding the efficient command line to do so. I have a
 > "instance" xml file, whose root is the tag <form>. I would like to
 > serialize only from form/tag1/tag2...
 > I thought about 2 possibilities:
 >
 > 1)in a xpl file:
 > <p:param name="instance" type="input"/>
 >
 > <p:processor name="oxf:file-serializer">
 > <p:input name="config">
 > <config>
 > <file>instance.xml</file>
 > <directory>c:/temp</directory>
 > </config>
 > </p:input>
 > <p:input name="data" href="#instance(WHAT TO PUT HERE?)"/>
 > </p:processor>

You can use the xpointer notation here:

<p:input name="data" href="#instance#xpointer(/form/tag1)"/>

This will create a document with root element <tag1>.

 > I think I should write with xpath, but I do not know which syntax is
 > appropriate here... Maybe with #xpointer, but I did not find its doc in
 > the orbeon website...
 >
 > 2)using an xslt processor
 > <p:processor name="oxf:xslt">
 > <p:input name="config" href="my-transformation.xsl"/>
 > <p:input name="data" href="#instance"/>
 > <p:output name="data" id="transformation-result"/>
 > </p:processor>
 >
 > <p:processor name="oxf:file-serializer">p:processor
 > name="oxf:file-serializer">
 > <p:input name="config">
 > <config>
 > <file>instance.xml </file>
 > <directory>c:/temp</directory>
 > </config>
 > </p:input>
 > <p:input name="data" href="#transformation-result"/>
 > </p:processor>
 >
 > and I wrote this my-transformation.xsl file:
 >
 > <?xml version="2.0" encoding="UTF-8"?>
 > <xsl:stylesheet version="2.0" xmlns:xsl="
 > http://www.w3.org/1999/XSL/Transform"
 > xmlns:fo="http://www.w3.org/1999/XSL/Format"
 > xmlns:xs="http://www.w3.org/2001/XMLSchema
 > <http://www.w3.org/2001/XMLSchema>"
 > xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
 > xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes"
 > <http://www.w3.org/2005/02/xpath-datatypes">><xsl:template match="/">
 > <xsl:copy-of select="//tag2" />
 > </xsl:template>
 > </xsl:stylesheet>

 > In this case, it works well if I use <xsl:copy-of select="//tag1" />,
 > but with "tag2", it doesn't work! (the xml file is then empty)
 > the only difference between the two tags is that tag2 has 2 namespace
 > declared... while tag1 has neither attribute nor xmlns declared...

It should work too. What happens if you put a debug attribute on these
lines:

   <p:input name="data" href="#instance"/>
   <p:input name="data" href="#transformation-result"/>

i.e.:

  <p:input name="data" href="#instance" debug="before"/>
  <p:input name="data" href="#transformation-result" debug="after/>

What are the resulting documents?

 > What I want to do is very basic, I'm sure there are many ways to solve
 > the problem, but I have not found it in the archive...
 > Thank's for helping,

-Erik




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: problem with serializing part of xml file

Erik Bruchez
Administrator
In reply to this post by marc.natale
This should be possible with the oxf:directory-scanner processor!

-Erik

Marc Natale wrote:
> ok,
> I've settled the issue after many tests... using the xpointer, and
> without declaring the good namespace above...
> However, has somebody designed something that enables the user to
> navigate in his drive in order to display the path and the directory
> where the user will save its xml output?
> Marc



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws