I am trying to do a XML sandbox where the user can type XML into a textarea and submit it to a web service.
I'd like to have a button that re-formats the submitted XML cleaning up the indentation, but I seems to not be able to find the right parameters to accomplish that. Anyone can help me? Thanks Here is the format.xpl script I wrote: <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:saxon="http://saxon.sf.net/" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <p:param name="instance" type="input"/> <p:param name="data" type="output"/> <!-- Parse the text as XML. This works --> <p:processor name="oxf:xslt"> <p:input name="data" href="#instance"/> <p:input name="config"> <xsl:stylesheet version="2.0"> <xsl:template match="/"> <xsl:copy-of select="saxon:parse(string(/))"/> </xsl:template> </xsl:stylesheet> </p:input> <p:output name="data" id="parsed" debug="parsed"/> </p:processor> <!-- serialize the XML as text, this does not work. I get everything on a single line --> <p:processor name="oxf:xslt"> <p:input name="data" href="#parsed"/> <p:input name="config"> <xsl:stylesheet version="2.0"> <xsl:import href="/config/theme/formatting.xsl"/> <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" name="xml"/> <xsl:template match="/"> <xsl:variable name="formatted"> <xsl:apply-templates mode="xml-formatting"> <xsl:with-param name="normalize-non-whitespace" select="false()"/> </xsl:apply-templates> </xsl:variable> <formatted-instance> <xsl:copy-of select="$formatted"/> </formatted-instance> </xsl:template> </xsl:stylesheet> </p:input> <p:output name="data" ref="data" debug="final"/> </p:processor> </p:config> -- 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 |
Administrator
|
Hi Alex,
I suspect you're having this problem because some of the classes used by the formatted code are not defined in your web page. Can you check if all the classes are defined, and if they are and you still have this problem, it will help if you can attach a complete example (XForms, page flow, XPL) so we can reproduce this. Alex On 6/9/06, [hidden email] <[hidden email]> wrote: > I am trying to do a XML sandbox where the user can type XML into a textarea and submit it to a web service. > I'd like to have a button that re-formats the submitted XML cleaning up the indentation, but I seems to not be able to find the right parameters to accomplish that. > Anyone can help me? Thanks > > Here is the format.xpl script I wrote: > > <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" > xmlns:saxon="http://saxon.sf.net/" > xmlns:oxf="http://www.orbeon.com/oxf/processors" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > > <p:param name="instance" type="input"/> > <p:param name="data" type="output"/> > > <!-- Parse the text as XML. This works --> > <p:processor name="oxf:xslt"> > <p:input name="data" href="#instance"/> > <p:input name="config"> > <xsl:stylesheet version="2.0"> > <xsl:template match="/"> > <xsl:copy-of select="saxon:parse(string(/))"/> > </xsl:template> > </xsl:stylesheet> > </p:input> > <p:output name="data" id="parsed" debug="parsed"/> > </p:processor> > > <!-- serialize the XML as text, this does not work. I get everything on a single line --> > <p:processor name="oxf:xslt"> > <p:input name="data" href="#parsed"/> > <p:input name="config"> > <xsl:stylesheet version="2.0"> > <xsl:import href="/config/theme/formatting.xsl"/> > <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" name="xml"/> > <xsl:template match="/"> > <xsl:variable name="formatted"> > <xsl:apply-templates mode="xml-formatting"> > <xsl:with-param name="normalize-non-whitespace" select="false()"/> > </xsl:apply-templates> > </xsl:variable> > <formatted-instance> > <xsl:copy-of select="$formatted"/> > </formatted-instance> > </xsl:template> > </xsl:stylesheet> > </p:input> > <p:output name="data" ref="data" debug="final"/> > </p:processor> > </p:config> > > > > > -- > 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 > > > -- Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/ -- 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
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Administrator
|
Note that our formatting stylesheets do not just indent XML: they
colorize it. So you go from an XML document to an HTML document. This wouldn't be very useful if what you want to do is to just nicely indent your XML in a textarea, for example. -Erik Alessandro Vernet wrote: > Hi Alex, > > I suspect you're having this problem because some of the classes used > by the formatted code are not defined in your web page. > > Can you check if all the classes are defined, and if they are and you > still have this problem, it will help if you can attach a complete > example (XForms, page flow, XPL) so we can reproduce this. > > Alex > > On 6/9/06, [hidden email] <[hidden email]> wrote: >> I am trying to do a XML sandbox where the user can type XML into a >> textarea and submit it to a web service. >> I'd like to have a button that re-formats the submitted XML cleaning >> up the indentation, but I seems to not be able to find the right >> parameters to accomplish that. >> Anyone can help me? Thanks >> >> Here is the format.xpl script I wrote: >> >> <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" >> xmlns:saxon="http://saxon.sf.net/" >> xmlns:oxf="http://www.orbeon.com/oxf/processors" >> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> >> >> <p:param name="instance" type="input"/> >> <p:param name="data" type="output"/> >> >> <!-- Parse the text as XML. This works --> >> <p:processor name="oxf:xslt"> >> <p:input name="data" href="#instance"/> >> <p:input name="config"> >> <xsl:stylesheet version="2.0"> >> <xsl:template match="/"> >> <xsl:copy-of select="saxon:parse(string(/))"/> >> </xsl:template> >> </xsl:stylesheet> >> </p:input> >> <p:output name="data" id="parsed" debug="parsed"/> >> </p:processor> >> >> <!-- serialize the XML as text, this does not work. I get everything >> on a single line --> >> <p:processor name="oxf:xslt"> >> <p:input name="data" href="#parsed"/> >> <p:input name="config"> >> <xsl:stylesheet version="2.0"> >> <xsl:import href="/config/theme/formatting.xsl"/> >> <xsl:output method="xml" omit-xml-declaration="yes" >> indent="yes" name="xml"/> >> <xsl:template match="/"> >> <xsl:variable name="formatted"> >> <xsl:apply-templates mode="xml-formatting"> >> <xsl:with-param >> name="normalize-non-whitespace" select="false()"/> >> </xsl:apply-templates> >> </xsl:variable> >> <formatted-instance> >> <xsl:copy-of select="$formatted"/> >> </formatted-instance> >> </xsl:template> >> </xsl:stylesheet> >> </p:input> >> <p:output name="data" ref="data" debug="final"/> >> </p:processor> >> </p:config> >> >> >> >> >> -- >> 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 >> >> >> > > > > ------------------------------------------------------------------------ > > > -- > 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 -- Orbeon - XForms Everywhere: http://www.orbeon.com/blog/ -- 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 |
that is exactly what I am trying to do. Basically I am looking for the inverse of the saxon:string function.
Any idea how to do that in a xpl script? Thanks. (I will try to post the complete example soon as soon as I cleanup it) On 6/13/06, Erik Bruchez <[hidden email]> wrote: Note that our formatting stylesheets do not just indent XML: they -- 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 |
Administrator
|
Alex,
With the appropriate CSS classes, you will have the indentation as well with the formatting stylesheet. That stylesheet generates a number of <span>, and the CSS will say that some of those spans have a display: block. If you don't have the appropriate CSS in place, everything will appear on one line. Alex On 6/13/06, Alex Cozzi <[hidden email]> wrote: > that is exactly what I am trying to do. Basically I am looking for the > inverse of the saxon:string function. > Any idea how to do that in a xpl script? Thanks. > (I will try to post the complete example soon as soon as I cleanup it) > > > > On 6/13/06, Erik Bruchez <[hidden email]> wrote: > > > Note that our formatting stylesheets do not just indent XML: they > colorize it. So you go from an XML document to an HTML document. > > This wouldn't be very useful if what you want to do is to just nicely > indent your XML in a textarea, for example. > > -Erik > > Alessandro Vernet wrote: > > Hi Alex, > > > > I suspect you're having this problem because some of the classes used > > by the formatted code are not defined in your web page. > > > > Can you check if all the classes are defined, and if they are and you > > still have this problem, it will help if you can attach a complete > > example (XForms, page flow, XPL) so we can reproduce this. > > > > Alex > > > > On 6/9/06, [hidden email] <[hidden email]> wrote: > >> I am trying to do a XML sandbox where the user can type XML into a > >> textarea and submit it to a web service. > >> I'd like to have a button that re-formats the submitted XML cleaning > >> up the indentation, but I seems to not be able to find the right > >> parameters to accomplish that. > >> Anyone can help me? Thanks > >> > >> Here is the format.xpl script I wrote: > >> > >> <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline " > >> xmlns:saxon="http://saxon.sf.net/" > >> xmlns:oxf="http://www.orbeon.com/oxf/processors " > >> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > >> > >> <p:param name="instance" type="input"/> > >> <p:param name="data" type="output"/> > >> > >> <!-- Parse the text as XML. This works --> > >> <p:processor name="oxf:xslt"> > >> <p:input name="data" href="#instance"/> > >> <p:input name="config"> > >> <xsl:stylesheet version="2.0"> > >> <xsl:template match="/"> > >> <xsl:copy-of > select="saxon:parse(string(/))"/> > >> </xsl:template> > >> </xsl:stylesheet> > >> </p:input> > >> <p:output name="data" id="parsed" debug="parsed"/> > >> </p:processor> > >> > >> <!-- serialize the XML as text, this does not work. I get everything > >> on a single line --> > >> <p:processor name="oxf:xslt"> > >> <p:input name="data" href="#parsed"/> > >> <p:input name="config"> > >> <xsl:stylesheet version="2.0"> > >> <xsl:import > href="/config/theme/formatting.xsl"/> > >> <xsl:output method="xml" omit-xml-declaration="yes" > >> indent="yes" name="xml"/> > >> <xsl:template match="/"> > >> <xsl:variable name="formatted"> > >> <xsl:apply-templates mode="xml-formatting"> > >> <xsl:with-param > >> name="normalize-non-whitespace" select="false()"/> > >> > </xsl:apply-templates> > >> </xsl:variable> > >> <formatted-instance> > >> <xsl:copy-of > select="$formatted"/> > >> </formatted-instance> > >> </xsl:template> > >> </xsl:stylesheet> > >> </p:input> > >> <p:output name="data" ref="data" debug="final"/> > >> </p:processor> > >> </p:config> > >> > >> > >> > >> > >> -- > >> 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 > >> > >> > >> > > > > > > > > > ------------------------------------------------------------------------ > > > > > > -- > > 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 > > > -- > Orbeon - XForms Everywhere: > http://www.orbeon.com/blog/ > > > > > -- > > 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 > > > > > > -- > 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 > > > -- Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/ -- 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
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Administrator
|
Alex,
But I think Alex (Cozzi) wants to store the result in a textarea. Am I right? -Erik Alessandro Vernet wrote: > Alex, > > With the appropriate CSS classes, you will have the indentation as > well with the formatting stylesheet. That stylesheet generates a > number of <span>, and the CSS will say that some of those spans have a > display: block. If you don't have the appropriate CSS in place, > everything will appear on one line. > > Alex > > On 6/13/06, Alex Cozzi <[hidden email]> wrote: >> that is exactly what I am trying to do. Basically I am looking for the >> inverse of the saxon:string function. >> Any idea how to do that in a xpl script? Thanks. >> (I will try to post the complete example soon as soon as I cleanup it) >> >> >> >> On 6/13/06, Erik Bruchez <[hidden email]> wrote: >> > >> Note that our formatting stylesheets do not just indent XML: they >> colorize it. So you go from an XML document to an HTML document. >> >> This wouldn't be very useful if what you want to do is to just nicely >> indent your XML in a textarea, for example. >> >> -Erik >> >> Alessandro Vernet wrote: >> > Hi Alex, >> > >> > I suspect you're having this problem because some of the classes used >> > by the formatted code are not defined in your web page. >> > >> > Can you check if all the classes are defined, and if they are and you >> > still have this problem, it will help if you can attach a complete >> > example (XForms, page flow, XPL) so we can reproduce this. >> > >> > Alex >> > >> > On 6/9/06, [hidden email] <[hidden email]> wrote: >> >> I am trying to do a XML sandbox where the user can type XML into a >> >> textarea and submit it to a web service. >> >> I'd like to have a button that re-formats the submitted XML cleaning >> >> up the indentation, but I seems to not be able to find the right >> >> parameters to accomplish that. >> >> Anyone can help me? Thanks >> >> >> >> Here is the format.xpl script I wrote: >> >> >> >> <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline " >> >> xmlns:saxon="http://saxon.sf.net/" >> >> xmlns:oxf="http://www.orbeon.com/oxf/processors " >> >> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> >> >> >> >> <p:param name="instance" type="input"/> >> >> <p:param name="data" type="output"/> >> >> >> >> <!-- Parse the text as XML. This works --> >> >> <p:processor name="oxf:xslt"> >> >> <p:input name="data" href="#instance"/> >> >> <p:input name="config"> >> >> <xsl:stylesheet version="2.0"> >> >> <xsl:template match="/"> >> >> <xsl:copy-of >> select="saxon:parse(string(/))"/> >> >> </xsl:template> >> >> </xsl:stylesheet> >> >> </p:input> >> >> <p:output name="data" id="parsed" debug="parsed"/> >> >> </p:processor> >> >> >> >> <!-- serialize the XML as text, this does not work. I get everything >> >> on a single line --> >> >> <p:processor name="oxf:xslt"> >> >> <p:input name="data" href="#parsed"/> >> >> <p:input name="config"> >> >> <xsl:stylesheet version="2.0"> >> >> <xsl:import >> href="/config/theme/formatting.xsl"/> >> >> <xsl:output method="xml" omit-xml-declaration="yes" >> >> indent="yes" name="xml"/> >> >> <xsl:template match="/"> >> >> <xsl:variable name="formatted"> >> >> <xsl:apply-templates mode="xml-formatting"> >> >> <xsl:with-param >> >> name="normalize-non-whitespace" select="false()"/> >> >> >> </xsl:apply-templates> >> >> </xsl:variable> >> >> <formatted-instance> >> >> <xsl:copy-of >> select="$formatted"/> >> >> </formatted-instance> >> >> </xsl:template> >> >> </xsl:stylesheet> >> >> </p:input> >> >> <p:output name="data" ref="data" debug="final"/> >> >> </p:processor> >> >> </p:config> >> >> >> >> >> >> >> >> >> >> -- >> >> 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 >> >> >> >> >> >> >> > >> > >> > >> > >> ------------------------------------------------------------------------ >> > >> > >> > -- >> > 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 >> >> >> -- >> Orbeon - XForms Everywhere: >> http://www.orbeon.com/blog/ >> >> >> >> >> -- >> >> 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 >> >> >> >> >> >> -- >> 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 >> >> >> > > > > ------------------------------------------------------------------------ > > > -- > 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 -- Orbeon - XForms Everywhere: http://www.orbeon.com/blog/ -- 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 |
That is right. What I am trying to achieve is the following: the user types XML text into a text area, and then he presses a button and the textarea gets re-formatted with the right indentation. It is to help users enter xml correctly. I don't want spans and stuff, I would like to just take an xml document and convert all
< into < and to keep the right indentation. Thanks. On 6/13/06, Erik Bruchez <[hidden email]> wrote: Alex, -- 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 |
Administrator
|
That's a good idea and a good feature to have, but you will have to
write your own reformatting code (or find such code somewhere else) as we don't have exactly that in OPS at the moment. If you do write or find such code, that would be a great contribution to OPS by the way ;-) -Erik Alex Cozzi wrote: > That is right. What I am trying to achieve is the following: the user > types XML text into a text area, and then he presses a button and the > textarea gets re-formatted with the right indentation. It is to help > users enter xml correctly. I don't want spans and stuff, I would like to > just take an xml document and convert all > < into < and to keep the right indentation. > > Thanks. > > On 6/13/06, *Erik Bruchez* <[hidden email] > <mailto:[hidden email]>> wrote: > > Alex, > > But I think Alex (Cozzi) wants to store the result in a textarea. Am I > right? > > -Erik > > Alessandro Vernet wrote: > > Alex, > > > > With the appropriate CSS classes, you will have the indentation as > > well with the formatting stylesheet. That stylesheet generates a > > number of <span>, and the CSS will say that some of those spans > have a > > display: block. If you don't have the appropriate CSS in place, > > everything will appear on one line. > > > > Alex > > > > On 6/13/06, Alex Cozzi <[hidden email] > <mailto:[hidden email]>> wrote: > >> that is exactly what I am trying to do. Basically I am looking > for the > >> inverse of the saxon:string function. > >> Any idea how to do that in a xpl script? Thanks. > >> (I will try to post the complete example soon as soon as I > cleanup it) > >> > >> > >> > >> On 6/13/06, Erik Bruchez < [hidden email] > <mailto:[hidden email]>> wrote: > >> > > >> Note that our formatting stylesheets do not just indent XML: they > >> colorize it. So you go from an XML document to an HTML document. > >> > >> This wouldn't be very useful if what you want to do is to just > nicely > >> indent your XML in a textarea, for example. > >> > >> -Erik > >> > >> Alessandro Vernet wrote: > >> > Hi Alex, > >> > > >> > I suspect you're having this problem because some of the > classes used > >> > by the formatted code are not defined in your web page. > >> > > >> > Can you check if all the classes are defined, and if they are > and you > >> > still have this problem, it will help if you can attach a complete > >> > example (XForms, page flow, XPL) so we can reproduce this. > >> > > >> > Alex > >> > > >> > On 6/9/06, [hidden email] <mailto:[hidden email]> > <[hidden email] <mailto:[hidden email]>> wrote: > >> >> I am trying to do a XML sandbox where the user can type XML > into a > >> >> textarea and submit it to a web service. > >> >> I'd like to have a button that re-formats the submitted XML > cleaning > >> >> up the indentation, but I seems to not be able to find the right > >> >> parameters to accomplish that. > >> >> Anyone can help me? Thanks > >> >> > >> >> Here is the format.xpl script I wrote: > >> >> > >> >> <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline " > >> >> xmlns:saxon=" http://saxon.sf.net/" > >> >> xmlns:oxf="http://www.orbeon.com/oxf/processors " > >> >> xmlns:xsl=" http://www.w3.org/1999/XSL/Transform"> > >> >> > >> >> <p:param name="instance" type="input"/> > >> >> <p:param name="data" type="output"/> > >> >> > >> >> <!-- Parse the text as XML. This works --> > >> >> <p:processor name="oxf:xslt"> > >> >> <p:input name="data" href="#instance"/> > >> >> <p:input name="config"> > >> >> <xsl:stylesheet version="2.0"> > >> >> <xsl:template match="/"> > >> >> <xsl:copy-of > >> select="saxon:parse(string(/))"/> > >> >> </xsl:template> > >> >> </xsl:stylesheet> > >> >> </p:input> > >> >> <p:output name="data" id="parsed" debug="parsed"/> > >> >> </p:processor> > >> >> > >> >> <!-- serialize the XML as text, this does not work. I get > everything > >> >> on a single line --> > >> >> <p:processor name="oxf:xslt"> > >> >> <p:input name="data" href="#parsed"/> > >> >> <p:input name="config"> > >> >> <xsl:stylesheet version="2.0"> > >> >> <xsl:import > >> href="/config/theme/formatting.xsl"/> > >> >> <xsl:output method="xml" > omit-xml-declaration="yes" > >> >> indent="yes" name="xml"/> > >> >> <xsl:template match="/"> > >> >> <xsl:variable name="formatted"> > >> >> <xsl:apply-templates > mode="xml-formatting"> > >> >> <xsl:with-param > >> >> name="normalize-non-whitespace" select="false()"/> > >> >> > >> </xsl:apply-templates> > >> >> </xsl:variable> > >> >> <formatted-instance> > >> >> <xsl:copy-of > >> select="$formatted"/> > >> >> </formatted-instance> > >> >> </xsl:template> > >> >> </xsl:stylesheet> > >> >> </p:input> > >> >> <p:output name="data" ref="data" debug="final"/> > >> >> </p:processor> > >> >> </p:config> > >> >> > >> >> > >> >> > >> >> > >> >> -- > >> >> You receive this message as a subscriber of the > >> >> [hidden email] <mailto:[hidden email]> > mailing list. > >> >> To unsubscribe: > >> mailto:[hidden email] > <mailto:[hidden email]> > >> >> For general help: mailto: [hidden email]?subject=help > <http://sympa@...?subject=help> > >> >> ObjectWeb mailing lists service home page: > >> http://www.objectweb.org/wws > >> >> > >> >> > >> >> > >> > > >> > > >> > > >> > > >> > ------------------------------------------------------------------------ > > >> > > >> > > >> > -- > >> > You receive this message as a subscriber of the > [hidden email] <mailto:[hidden email]> > >> mailing list. > >> > To unsubscribe: > >> mailto:[hidden email] > <mailto:[hidden email]> > >> > For general help: mailto:[hidden email] > <mailto:[hidden email]> ?subject=help > >> > ObjectWeb mailing lists service home page: > http://www.objectweb.org/wws > >> > >> > >> -- > >> Orbeon - XForms Everywhere: > >> http://www.orbeon.com/blog/ > >> > >> > >> > >> > >> -- > >> > >> You receive this message as a subscriber of the > [hidden email] <mailto:[hidden email]> > >> mailing list. > >> To unsubscribe: mailto: [hidden email] > <mailto:[hidden email]> > >> For general help: mailto: [hidden email] > <mailto:[hidden email]>?subject=help > >> ObjectWeb mailing lists service home page: > http://www.objectweb.org/wws > >> > >> > >> > >> > >> > >> -- > >> You receive this message as a subscriber of the > [hidden email] <mailto:[hidden email]> > >> mailing list. > >> To unsubscribe: mailto: [hidden email] > <mailto:[hidden email]> > >> For general help: mailto:[hidden email] > <mailto:[hidden email]>?subject=help > >> ObjectWeb mailing lists service home page: > http://www.objectweb.org/wws > >> > >> > >> > > > > > > > > > ------------------------------------------------------------------------ > > > > > > -- > > You receive this message as a subscriber of the > [hidden email] <mailto:[hidden email]> mailing list. > > To unsubscribe: mailto:[hidden email] > <mailto:[hidden email]> > > For general help: mailto: [hidden email] > <mailto:[hidden email]>?subject=help > > ObjectWeb mailing lists service home page: > http://www.objectweb.org/wws > > > -- > Orbeon - XForms Everywhere: > http://www.orbeon.com/blog/ > > > > > -- > You receive this message as a subscriber of the > [hidden email] <mailto:[hidden email]> mailing list. > To unsubscribe: mailto:[hidden email] > <mailto:[hidden email]> > For general help: mailto:[hidden email] > <mailto:[hidden email]>?subject=help > ObjectWeb mailing lists service home page: http://www.objectweb.org/wws > > > > > ------------------------------------------------------------------------ > > > -- > 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 -- Orbeon - XForms Everywhere: http://www.orbeon.com/blog/ -- 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 |
In reply to this post by alex cozzi
The Xerces XMLSerializer has stuff to do auto-indenting (pretty
printing) I believe -----Original Message----- From: Erik Bruchez [mailto:[hidden email]] On Behalf Of Erik Bruchez Sent: 14 June 2006 17:48 To: [hidden email] Subject: Re: [ops-users] reformat user-entered XML That's a good idea and a good feature to have, but you will have to write your own reformatting code (or find such code somewhere else) as we don't have exactly that in OPS at the moment. If you do write or find such code, that would be a great contribution to OPS by the way ;-) -Erik Alex Cozzi wrote: > That is right. What I am trying to achieve is the following: the user > types XML text into a text area, and then he presses a button and the > textarea gets re-formatted with the right indentation. It is to help > users enter xml correctly. I don't want spans and stuff, I would like to > just take an xml document and convert all > < into < and to keep the right indentation. > > Thanks. > > On 6/13/06, *Erik Bruchez* <[hidden email] > <mailto:[hidden email]>> wrote: > > Alex, > > But I think Alex (Cozzi) wants to store the result in a textarea. > right? > > -Erik > > Alessandro Vernet wrote: > > Alex, > > > > With the appropriate CSS classes, you will have the indentation > > well with the formatting stylesheet. That stylesheet generates a > > number of <span>, and the CSS will say that some of those spans > have a > > display: block. If you don't have the appropriate CSS in place, > > everything will appear on one line. > > > > Alex > > > > On 6/13/06, Alex Cozzi <[hidden email] > <mailto:[hidden email]>> wrote: > >> that is exactly what I am trying to do. Basically I am looking > for the > >> inverse of the saxon:string function. > >> Any idea how to do that in a xpl script? Thanks. > >> (I will try to post the complete example soon as soon as I > cleanup it) > >> > >> > >> > >> On 6/13/06, Erik Bruchez < [hidden email] > <mailto:[hidden email]>> wrote: > >> > > >> Note that our formatting stylesheets do not just indent XML: > >> colorize it. So you go from an XML document to an HTML > >> > >> This wouldn't be very useful if what you want to do is to just > nicely > >> indent your XML in a textarea, for example. > >> > >> -Erik > >> > >> Alessandro Vernet wrote: > >> > Hi Alex, > >> > > >> > I suspect you're having this problem because some of the > classes used > >> > by the formatted code are not defined in your web page. > >> > > >> > Can you check if all the classes are defined, and if they > and you > >> > still have this problem, it will help if you can attach a > >> > example (XForms, page flow, XPL) so we can reproduce this. > >> > > >> > Alex > >> > > >> > On 6/9/06, [hidden email] <mailto:[hidden email]> > <[hidden email] <mailto:[hidden email]>> wrote: > >> >> I am trying to do a XML sandbox where the user can type XML > into a > >> >> textarea and submit it to a web service. > >> >> I'd like to have a button that re-formats the submitted XML > cleaning > >> >> up the indentation, but I seems to not be able to find the > >> >> parameters to accomplish that. > >> >> Anyone can help me? Thanks > >> >> > >> >> Here is the format.xpl script I wrote: > >> >> > >> >> <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline " > >> >> xmlns:saxon=" http://saxon.sf.net/" > >> >> xmlns:oxf="http://www.orbeon.com/oxf/processors " > >> >> xmlns:xsl=" http://www.w3.org/1999/XSL/Transform"> > >> >> > >> >> <p:param name="instance" type="input"/> > >> >> <p:param name="data" type="output"/> > >> >> > >> >> <!-- Parse the text as XML. This works --> > >> >> <p:processor name="oxf:xslt"> > >> >> <p:input name="data" href="#instance"/> > >> >> <p:input name="config"> > >> >> <xsl:stylesheet version="2.0"> > >> >> <xsl:template match="/"> > >> >> <xsl:copy-of > >> select="saxon:parse(string(/))"/> > >> >> </xsl:template> > >> >> </xsl:stylesheet> > >> >> </p:input> > >> >> <p:output name="data" id="parsed" debug="parsed"/> > >> >> </p:processor> > >> >> > >> >> <!-- serialize the XML as text, this does not work. I get > everything > >> >> on a single line --> > >> >> <p:processor name="oxf:xslt"> > >> >> <p:input name="data" href="#parsed"/> > >> >> <p:input name="config"> > >> >> <xsl:stylesheet version="2.0"> > >> >> <xsl:import > >> href="/config/theme/formatting.xsl"/> > >> >> <xsl:output method="xml" > omit-xml-declaration="yes" > >> >> indent="yes" name="xml"/> > >> >> <xsl:template match="/"> > >> >> <xsl:variable name="formatted"> > >> >> <xsl:apply-templates > mode="xml-formatting"> > >> >> <xsl:with-param > >> >> name="normalize-non-whitespace" select="false()"/> > >> >> > >> </xsl:apply-templates> > >> >> </xsl:variable> > >> >> <formatted-instance> > >> >> <xsl:copy-of > >> select="$formatted"/> > >> >> </formatted-instance> > >> >> </xsl:template> > >> >> </xsl:stylesheet> > >> >> </p:input> > >> >> <p:output name="data" ref="data" debug="final"/> > >> >> </p:processor> > >> >> </p:config> > >> >> > >> >> > >> >> > >> >> > >> >> -- > >> >> You receive this message as a subscriber of the > >> >> [hidden email] <mailto:[hidden email]> > mailing list. > >> >> To unsubscribe: > >> mailto:[hidden email] > <mailto:[hidden email]> > >> >> For general help: mailto: [hidden email]?subject=help > <http://sympa@...?subject=help> > >> >> ObjectWeb mailing lists service home page: > >> http://www.objectweb.org/wws > >> >> > >> >> > >> >> > >> > > >> > > >> > > >> > > >> > > > >> > > >> > > >> > -- > >> > You receive this message as a subscriber of the > [hidden email] <mailto:[hidden email]> > >> mailing list. > >> > To unsubscribe: > >> mailto:[hidden email] > <mailto:[hidden email]> > >> > For general help: mailto:[hidden email] > <mailto:[hidden email]> ?subject=help > >> > ObjectWeb mailing lists service home page: > http://www.objectweb.org/wws > >> > >> > >> -- > >> Orbeon - XForms Everywhere: > >> http://www.orbeon.com/blog/ > >> > >> > >> > >> > >> -- > >> > >> You receive this message as a subscriber of the > [hidden email] <mailto:[hidden email]> > >> mailing list. > >> To unsubscribe: mailto: [hidden email] > <mailto:[hidden email]> > >> For general help: mailto: [hidden email] > <mailto:[hidden email]>?subject=help > >> ObjectWeb mailing lists service home page: > http://www.objectweb.org/wws > >> > >> > >> > >> > >> > >> -- > >> You receive this message as a subscriber of the > [hidden email] <mailto:[hidden email]> > >> mailing list. > >> To unsubscribe: mailto: [hidden email] > <mailto:[hidden email]> > >> For general help: mailto:[hidden email] > <mailto:[hidden email]>?subject=help > >> ObjectWeb mailing lists service home page: > http://www.objectweb.org/wws > >> > >> > >> > > > > > > > > > > > > > > > -- > > You receive this message as a subscriber of the > [hidden email] <mailto:[hidden email]> mailing > > To unsubscribe: mailto:[hidden email] > <mailto:[hidden email]> > > For general help: mailto: [hidden email] > <mailto:[hidden email]>?subject=help > > ObjectWeb mailing lists service home page: > http://www.objectweb.org/wws > > > -- > Orbeon - XForms Everywhere: > http://www.orbeon.com/blog/ > > > > > -- > You receive this message as a subscriber of the > [hidden email] <mailto:[hidden email]> mailing > To unsubscribe: mailto:[hidden email] > <mailto:[hidden email]> > For general help: mailto:[hidden email] > <mailto:[hidden email]>?subject=help > ObjectWeb mailing lists service home page: > > > > > ------------------------------------------------------------------------ > > > -- > 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 -- Orbeon - XForms Everywhere: http://www.orbeon.com/blog/ -- 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 |
Administrator
|
dom4j will do this as well. We have a static public method that you
should be able to easily call from XSLT to do this: org.orbeon.oxf.xml.dom4j.Dom4jUtils.domToString(doc) Alex On 6/14/06, Stephen Bayliss <[hidden email]> wrote: > The Xerces XMLSerializer has stuff to do auto-indenting (pretty > printing) I believe > > -----Original Message----- > From: Erik Bruchez [mailto:[hidden email]] On Behalf Of Erik Bruchez > Sent: 14 June 2006 17:48 > To: [hidden email] > Subject: Re: [ops-users] reformat user-entered XML > > That's a good idea and a good feature to have, but you will have to > write your own reformatting code (or find such code somewhere else) as > we don't have exactly that in OPS at the moment. > > If you do write or find such code, that would be a great contribution to > > OPS by the way ;-) > > -Erik > > Alex Cozzi wrote: > > That is right. What I am trying to achieve is the following: the user > > types XML text into a text area, and then he presses a button and the > > > textarea gets re-formatted with the right indentation. It is to help > > users enter xml correctly. I don't want spans and stuff, I would like > to > > just take an xml document and convert all > > < into < and to keep the right indentation. > > > > Thanks. > > > > On 6/13/06, *Erik Bruchez* <[hidden email] > > <mailto:[hidden email]>> wrote: > > > > Alex, > > > > But I think Alex (Cozzi) wants to store the result in a textarea. > Am I > > right? > > > > -Erik > > > > Alessandro Vernet wrote: > > > Alex, > > > > > > With the appropriate CSS classes, you will have the indentation > as > > > well with the formatting stylesheet. That stylesheet generates > a > > > number of <span>, and the CSS will say that some of those spans > > have a > > > display: block. If you don't have the appropriate CSS in place, > > > everything will appear on one line. > > > > > > Alex > > > > > > On 6/13/06, Alex Cozzi <[hidden email] > > <mailto:[hidden email]>> wrote: > > >> that is exactly what I am trying to do. Basically I am looking > > for the > > >> inverse of the saxon:string function. > > >> Any idea how to do that in a xpl script? Thanks. > > >> (I will try to post the complete example soon as soon as I > > cleanup it) > > >> > > >> > > >> > > >> On 6/13/06, Erik Bruchez < [hidden email] > > <mailto:[hidden email]>> wrote: > > >> > > > >> Note that our formatting stylesheets do not just indent XML: > they > > >> colorize it. So you go from an XML document to an HTML > document. > > >> > > >> This wouldn't be very useful if what you want to do is to just > > nicely > > >> indent your XML in a textarea, for example. > > >> > > >> -Erik > > >> > > >> Alessandro Vernet wrote: > > >> > Hi Alex, > > >> > > > >> > I suspect you're having this problem because some of the > > classes used > > >> > by the formatted code are not defined in your web page. > > >> > > > >> > Can you check if all the classes are defined, and if they > are > > and you > > >> > still have this problem, it will help if you can attach a > complete > > >> > example (XForms, page flow, XPL) so we can reproduce this. > > >> > > > >> > Alex > > >> > > > >> > On 6/9/06, [hidden email] <mailto:[hidden email]> > > <[hidden email] <mailto:[hidden email]>> wrote: > > >> >> I am trying to do a XML sandbox where the user can type XML > > into a > > >> >> textarea and submit it to a web service. > > >> >> I'd like to have a button that re-formats the submitted XML > > cleaning > > >> >> up the indentation, but I seems to not be able to find the > right > > >> >> parameters to accomplish that. > > >> >> Anyone can help me? Thanks > > >> >> > > >> >> Here is the format.xpl script I wrote: > > >> >> > > >> >> <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline " > > >> >> xmlns:saxon=" http://saxon.sf.net/" > > >> >> xmlns:oxf="http://www.orbeon.com/oxf/processors " > > >> >> xmlns:xsl=" http://www.w3.org/1999/XSL/Transform"> > > >> >> > > >> >> <p:param name="instance" type="input"/> > > >> >> <p:param name="data" type="output"/> > > >> >> > > >> >> <!-- Parse the text as XML. This works --> > > >> >> <p:processor name="oxf:xslt"> > > >> >> <p:input name="data" href="#instance"/> > > >> >> <p:input name="config"> > > >> >> <xsl:stylesheet version="2.0"> > > >> >> <xsl:template match="/"> > > >> >> <xsl:copy-of > > >> select="saxon:parse(string(/))"/> > > >> >> </xsl:template> > > >> >> </xsl:stylesheet> > > >> >> </p:input> > > >> >> <p:output name="data" id="parsed" debug="parsed"/> > > >> >> </p:processor> > > >> >> > > >> >> <!-- serialize the XML as text, this does not work. I get > > everything > > >> >> on a single line --> > > >> >> <p:processor name="oxf:xslt"> > > >> >> <p:input name="data" href="#parsed"/> > > >> >> <p:input name="config"> > > >> >> <xsl:stylesheet version="2.0"> > > >> >> <xsl:import > > >> href="/config/theme/formatting.xsl"/> > > >> >> <xsl:output method="xml" > > omit-xml-declaration="yes" > > >> >> indent="yes" name="xml"/> > > >> >> <xsl:template match="/"> > > >> >> <xsl:variable name="formatted"> > > >> >> <xsl:apply-templates > > mode="xml-formatting"> > > >> >> <xsl:with-param > > >> >> name="normalize-non-whitespace" select="false()"/> > > >> >> > > >> </xsl:apply-templates> > > >> >> </xsl:variable> > > >> >> <formatted-instance> > > >> >> <xsl:copy-of > > >> select="$formatted"/> > > >> >> </formatted-instance> > > >> >> </xsl:template> > > >> >> </xsl:stylesheet> > > >> >> </p:input> > > >> >> <p:output name="data" ref="data" debug="final"/> > > >> >> </p:processor> > > >> >> </p:config> > > >> >> > > >> >> > > >> >> > > >> >> > > >> >> -- > > >> >> You receive this message as a subscriber of the > > >> >> [hidden email] <mailto:[hidden email]> > > mailing list. > > >> >> To unsubscribe: > > >> mailto:[hidden email] > > <mailto:[hidden email]> > > >> >> For general help: mailto: [hidden email]?subject=help > > <http://sympa@...?subject=help> > > >> >> ObjectWeb mailing lists service home page: > > >> http://www.objectweb.org/wws > > >> >> > > >> >> > > >> >> > > >> > > > >> > > > >> > > > >> > > > >> > > > ------------------------------------------------------------------------ > > > > >> > > > >> > > > >> > -- > > >> > You receive this message as a subscriber of the > > [hidden email] <mailto:[hidden email]> > > >> mailing list. > > >> > To unsubscribe: > > >> mailto:[hidden email] > > <mailto:[hidden email]> > > >> > For general help: mailto:[hidden email] > > <mailto:[hidden email]> ?subject=help > > >> > ObjectWeb mailing lists service home page: > > http://www.objectweb.org/wws > > >> > > >> > > >> -- > > >> Orbeon - XForms Everywhere: > > >> http://www.orbeon.com/blog/ > > >> > > >> > > >> > > >> > > >> -- > > >> > > >> You receive this message as a subscriber of the > > [hidden email] <mailto:[hidden email]> > > >> mailing list. > > >> To unsubscribe: mailto: [hidden email] > > <mailto:[hidden email]> > > >> For general help: mailto: [hidden email] > > <mailto:[hidden email]>?subject=help > > >> ObjectWeb mailing lists service home page: > > http://www.objectweb.org/wws > > >> > > >> > > >> > > >> > > >> > > >> -- > > >> You receive this message as a subscriber of the > > [hidden email] <mailto:[hidden email]> > > >> mailing list. > > >> To unsubscribe: mailto: [hidden email] > > <mailto:[hidden email]> > > >> For general help: mailto:[hidden email] > > <mailto:[hidden email]>?subject=help > > >> ObjectWeb mailing lists service home page: > > http://www.objectweb.org/wws > > >> > > >> > > >> > > > > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > > > > -- > > > You receive this message as a subscriber of the > > [hidden email] <mailto:[hidden email]> mailing > list. > > > To unsubscribe: mailto:[hidden email] > > <mailto:[hidden email]> > > > For general help: mailto: [hidden email] > > <mailto:[hidden email]>?subject=help > > > ObjectWeb mailing lists service home page: > > http://www.objectweb.org/wws > > > > > > -- > > Orbeon - XForms Everywhere: > > http://www.orbeon.com/blog/ > > > > > > > > > > -- > > You receive this message as a subscriber of the > > [hidden email] <mailto:[hidden email]> mailing > list. > > To unsubscribe: mailto:[hidden email] > > <mailto:[hidden email]> > > For general help: mailto:[hidden email] > > <mailto:[hidden email]>?subject=help > > ObjectWeb mailing lists service home page: > http://www.objectweb.org/wws > > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > -- > > 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 > > > -- > Orbeon - XForms Everywhere: > http://www.orbeon.com/blog/ > > > > > > > -- > 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 > > > -- Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/ -- 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
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
sorry for being dense, but how do you call org.orbeon.oxf.xml.dom4j
.Dom4jUtils.domToString(doc) from within a xsl stylesheet? or do you mean I should use a Java processor?
On 6/14/06, Alessandro Vernet <[hidden email]> wrote:
dom4j will do this as well. We have a static public method that you -- 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 |
Alex,
To call a Java static method from within an XSL stylesheet, do this: * First, in the stylesheet, declare a namespace that points to the class that has the method you want to call: <xsl:transform xmlns:xsl="..." version="2.0" xmlns:du="java:org.orbeon.oxf.xml.dom4j.Dom4jUtils"> * Then, to call a static method of that class, just treat it as a function call, using the namespace prefix you assigned: <xsl:value-of select="du:domToString($document-node-of-the-doc-I-want-to-serialize)"/> A couple caveats: * I haven't looked at Dom4jUtils, so I'm not 100% sure this method needs a document node as its argument. Maybe someone else can confirm? * This is how it works with Saxon 8.1.1, which is the default XSLT engine in OPS. I don't know if it works the same with other XSLT processors. * Although I say "default" XSLT processor, it isn't, quite, because extension functions are turned off by default. To get a Saxon processor that will call external functions, use "oxf:unsafe-xslt" as your processor instead of "oxf:xslt". The two processors have the same XPL syntax, so you won't need to change anything other than the processor name. * Saxon has specific rules for how it converts function arguments and results. Consult the documentation: http://www.saxonica.com/documentation/extensibility/intro.html (Note that this documentation is for Saxon 8.7. Docs for earlier versions are available to download on that site.) --- Hope this is helpful. Jeff Jones TWC Interactive Alex Cozzi wrote: > sorry for being dense, but how do you call org.orbeon.oxf.xml.dom4j > .Dom4jUtils.domToString(doc) from within a xsl stylesheet? or do you > mean I should use a Java processor? > > > On 6/14/06, *Alessandro Vernet* <[hidden email] > <mailto:[hidden email]>> wrote: > > dom4j will do this as well. We have a static public method that you > should be able to easily call from XSLT to do this: > > org.orbeon.oxf.xml.dom4j.Dom4jUtils.domToString(doc) > > Alex -- 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 |
Free forum by Nabble | Edit this page |