Displaying Raw XML

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

Displaying Raw XML

stacyladnier
I have a model instance that contains XML of course, we will call it 'my-instance':

<myxml>
    <first>
        <second>Data goes here</second>
    </first>
</myxml>

Further down in the form, I would like to display the contents of the model in their raw XML format. My users are experience enough with XML that they like to see the XML format and also sometimes edit the XML directly. I would like to provide this to them in two different ways and cannot seem to make it work. I have tried to search for how to do this but found nothing definitive.

1. Textarea containing entire raw XML content, including tags, that a user can edit and commit back to the db. Committing to the db is something I will be able to do. I am hung up on getting the raw XML to display in the textarea.

2. A non-editable view of the XML, so basically and HTML page with the raw contents of the XML displayed within it.

I apologize if this is a newbie question. I hope it is simple enough to answer.

Stacy
Reply | Threaded
Open this post in threaded view
|

RE: Displaying Raw XML

Steven Kerr
Stacy

I can't see any replies to this question.  I am not an expert on Orbeon,
but the second part of your question should be easy.

If you place the following code in your page an Orbeon widget will allow
you to view all the instance XML.  You can select the one you want to
view.

<widget:xforms-instance-inspector
xmlns:widget="http://orbeon.org/oxf/xml/widget"/>

It might also be possible to customise it.  With regard to editing the
XML, this sounds very possible but I will have to leave that for an
expert to answer.  Alternatively, you could use a separate product.
i.e.
http://www.ephox.com/products/editliveforxml/
But that might be overkill for what you are doing.

Cheers

Steve


-----Original Message-----
From: stacyladnier [mailto:[hidden email]]
Sent: Friday, 20 November 2009 05:47
To: [hidden email]
Subject: [ops-users] Displaying Raw XML


I have a model instance that contains XML of course, we will call it
'my-instance':

<myxml>
    <first>
        <second>Data goes here</second>
    </first>
</myxml>

Further down in the form, I would like to display the contents of the
model in their raw XML format. My users are experience enough with XML
that they like to see the XML format and also sometimes edit the XML
directly. I would like to provide this to them in two different ways and
cannot seem to make it work. I have tried to search for how to do this
but found nothing definitive.

1. Textarea containing entire raw XML content, including tags, that a
user can edit and commit back to the db. Committing to the db is
something I will be able to do. I am hung up on getting the raw XML to
display in the textarea.

2. A non-editable view of the XML, so basically and HTML page with the
raw contents of the XML displayed within it.

I apologize if this is a newbie question. I hope it is simple enough to
answer.

Stacy
--
View this message in context:
http://n4.nabble.com/Displaying-Raw-XML-tp624201p624201.html
Sent from the ObjectWeb OPS - Users mailing list archive at Nabble.com.



--
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
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: RE: Displaying Raw XML

Erik Bruchez-3
Re #2, I think what you want to do is serialize the instance to obtain
text (as the XForms Inspector does). Try something like this:

<xforms:output value="saxon:serialize(instance('my-instance'), 'xml')"/>

With appropriate CSS, e.g. white-space: pre,  the resulting text
should be reasonably formatted.

Re #1, you will need to serialize the instance as text into an element
or attribute. Then you can edit it in a textarea. Conversely, you will
need to use saxon:parse() to convert back the text edited by the user
into XML that can then be inserted back into the instance.

This is what Form Builder does BTW for the Edit Source feature.

-Erik

On Wed, Nov 25, 2009 at 8:43 PM, Steven Kerr
<[hidden email]> wrote:

> Stacy
>
> I can't see any replies to this question.  I am not an expert on Orbeon,
> but the second part of your question should be easy.
>
> If you place the following code in your page an Orbeon widget will allow
> you to view all the instance XML.  You can select the one you want to
> view.
>
> <widget:xforms-instance-inspector
> xmlns:widget="http://orbeon.org/oxf/xml/widget"/>
>
> It might also be possible to customise it.  With regard to editing the
> XML, this sounds very possible but I will have to leave that for an
> expert to answer.  Alternatively, you could use a separate product.
> i.e.
> http://www.ephox.com/products/editliveforxml/
> But that might be overkill for what you are doing.
>
> Cheers
>
> Steve
>
>
> -----Original Message-----
> From: stacyladnier [mailto:[hidden email]]
> Sent: Friday, 20 November 2009 05:47
> To: [hidden email]
> Subject: [ops-users] Displaying Raw XML
>
>
> I have a model instance that contains XML of course, we will call it
> 'my-instance':
>
> <myxml>
>    <first>
>        <second>Data goes here</second>
>    </first>
> </myxml>
>
> Further down in the form, I would like to display the contents of the
> model in their raw XML format. My users are experience enough with XML
> that they like to see the XML format and also sometimes edit the XML
> directly. I would like to provide this to them in two different ways and
> cannot seem to make it work. I have tried to search for how to do this
> but found nothing definitive.
>
> 1. Textarea containing entire raw XML content, including tags, that a
> user can edit and commit back to the db. Committing to the db is
> something I will be able to do. I am hung up on getting the raw XML to
> display in the textarea.
>
> 2. A non-editable view of the XML, so basically and HTML page with the
> raw contents of the XML displayed within it.
>
> I apologize if this is a newbie question. I hope it is simple enough to
> answer.
>
> Stacy
> --
> View this message in context:
> http://n4.nabble.com/Displaying-Raw-XML-tp624201p624201.html
> Sent from the ObjectWeb OPS - Users mailing list archive at Nabble.com.
>
>
>
> --
> 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
> OW2 mailing lists service home page: http://www.ow2.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
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: RE: Displaying Raw XML

stacyladnier
In reply to this post by stacyladnier
Eric and all,

I did come across the Edit Source feature and the use of serialize and
parse. I understand concept and use. However, I must be doing something
wrong as I still cannot get XML to display.

Below is the source I am working with (also attached). Interestingly,
originally I pull and replace the xmlfile-instance from eXist and text
will show up in the dialog, just not formatted as xml. When I hardcode
the instance data, no text shows up at all.

If anyone can point out what I am doing incorrectly, I would greatly
appreciate it!!

-Stacy

<html xmlns:xforms="http://www.w3.org/2002/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events"
      xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://orbeon.org/oxf/xml/formatting"
      xmlns:saxon="http://saxon.sf.net/">
    <head>
        <xforms:model>          
            <xforms:instance
id="xmlfile-instance"><metadata><first><second><third>Contains actual
text</third></second></first></metadata></xforms:instance>
            <xforms:instance
id="xmlfile-instance-copy"><metadata/></xforms:instance>
            <xforms:bind nodeset="instance('xmlfile-instance-copy')"
type="xxforms:xml"/>
        </xforms:model>
    </head>
    <body>
        <xxforms:dialog id="edit-xml-dialog" appearance="full"
level="modeless" close="true" draggable="true">
            <xforms:label>Edit XML</xforms:label>
            <xforms:group ref="instance('xmlfile-instance-copy')">
                <xforms:textarea ref="metadata"/>
            </xforms:group>
            <xxforms:hide ev:event="DOMActivate" dialog="edit-xml-dialog"/>
            <xforms:setvalue ev:event="xxforms-dialog-open" ref="metadata"
               
value="saxon:serialize(xxforms:instance('xmlfile-instance'), 'xml')"/>
        </xxforms:dialog>
       
        <table class="forms-gridtable">
            <tr><td><xforms:trigger
appearance="minimal"><xforms:label>Edit</xforms:label>
                <xforms:action ev:event="DOMActivate">
                    <xforms:insert
context="instance('xmlfile-instance-copy')"
origin="instance('xmlfile-instance')"/>
                    <xxforms:show dialog="edit-xml-dialog"/>
                </xforms:action>
            </xforms:trigger></td></tr>
            <tr/><!-- This is to work around a bug in IE -->
        </table>
        <widget:xforms-instance-inspector
xmlns:widget="http://orbeon.org/oxf/xml/widget"/>
    </body>
</html>


----- Original Message -----
From: Erik Bruchez <[hidden email]>
Date: Monday, November 30, 2009 9:54 pm
Subject: [ops-users] Re: RE: Displaying Raw XML

> Re #2, I think what you want to do is serialize the instance to obtain
> text (as the XForms Inspector does). Try something like this:
>
> <xforms:output value="saxon:serialize(instance('my-instance'),
> 'xml')"/>
> With appropriate CSS, e.g. white-space: pre,  the resulting text
> should be reasonably formatted.
>
> Re #1, you will need to serialize the instance as text into an element
> or attribute. Then you can edit it in a textarea. Conversely, you will
> need to use saxon:parse() to convert back the text edited by the user
> into XML that can then be inserted back into the instance.
>
> This is what Form Builder does BTW for the Edit Source feature.
>
> -Erik
>
> On Wed, Nov 25, 2009 at 8:43 PM, Steven Kerr
> <[hidden email]> wrote:
> > Stacy
> >
> > I can't see any replies to this question.  I am not an expert on
> Orbeon,> but the second part of your question should be easy.
> >
> > If you place the following code in your page an Orbeon widget
> will allow
> > you to view all the instance XML.  You can select the one you
> want to
> > view.
> >
> > <widget:xforms-instance-inspector
> > xmlns:widget="http://orbeon.org/oxf/xml/widget"/>
> >
> > It might also be possible to customise it.  With regard to
> editing the
> > XML, this sounds very possible but I will have to leave that for an
> > expert to answer.  Alternatively, you could use a separate product.
> > i.e.
> > http://www.ephox.com/products/editliveforxml/
> > But that might be overkill for what you are doing.
> >
> > Cheers
> >
> > Steve
> >
> >
> > -----Original Message-----
> > From: stacyladnier [mailto:[hidden email]]
> > Sent: Friday, 20 November 2009 05:47
> > To: [hidden email]
> > Subject: [ops-users] Displaying Raw XML
> >
> >
> > I have a model instance that contains XML of course, we will call it
> > 'my-instance':
> >
> > <myxml>
> >    <first>
> >        <second>Data goes here</second>
> >    </first>
> > </myxml>
> >
> > Further down in the form, I would like to display the contents of
> the> model in their raw XML format. My users are experience enough
> with XML
> > that they like to see the XML format and also sometimes edit the XML
> > directly. I would like to provide this to them in two different
> ways and
> > cannot seem to make it work. I have tried to search for how to do
> this> but found nothing definitive.
> >
> > 1. Textarea containing entire raw XML content, including tags,
> that a
> > user can edit and commit back to the db. Committing to the db is
> > something I will be able to do. I am hung up on getting the raw
> XML to
> > display in the textarea.
> >
> > 2. A non-editable view of the XML, so basically and HTML page
> with the
> > raw contents of the XML displayed within it.
> >
> > I apologize if this is a newbie question. I hope it is simple
> enough to
> > answer.
> >
> > Stacy
> > --
> > View this message in context:
> > http://n4.nabble.com/Displaying-Raw-XML-tp624201p624201.html
> > Sent from the ObjectWeb OPS - Users mailing list archive at
> Nabble.com.>
> >
> >
> > --
> > 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
> > OW2 mailing lists service home page: http://www.ow2.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
OW2 mailing lists service home page: http://www.ow2.org/wws

format-source-test.xhtml (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: RE: Displaying Raw XML

Erik Bruchez-3
Stacy,

A few issues with your code:

* the default XML namespace is set to the XHTML namespace, and also
applies to your instances
* in your dialog, your XPath does not point properly to the
<metadata/> element of the second instance

Try something like this: http://pastie.org/722883

-Erik

On Tue, Dec 1, 2009 at 8:02 AM,  <[hidden email]> wrote:

> Eric and all,
>
> I did come across the Edit Source feature and the use of serialize and
> parse. I understand concept and use. However, I must be doing something
> wrong as I still cannot get XML to display.
>
> Below is the source I am working with (also attached). Interestingly,
> originally I pull and replace the xmlfile-instance from eXist and text
> will show up in the dialog, just not formatted as xml. When I hardcode
> the instance data, no text shows up at all.
>
> If anyone can point out what I am doing incorrectly, I would greatly
> appreciate it!!
>
> -Stacy
>
> <html xmlns:xforms="http://www.w3.org/2002/xforms"
>      xmlns:ev="http://www.w3.org/2001/xml-events"
>      xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
>      xmlns="http://www.w3.org/1999/xhtml"
>      xmlns:f="http://orbeon.org/oxf/xml/formatting"
>      xmlns:saxon="http://saxon.sf.net/">
>    <head>
>        <xforms:model>
>            <xforms:instance
> id="xmlfile-instance"><metadata><first><second><third>Contains actual
> text</third></second></first></metadata></xforms:instance>
>            <xforms:instance
> id="xmlfile-instance-copy"><metadata/></xforms:instance>
>            <xforms:bind nodeset="instance('xmlfile-instance-copy')"
> type="xxforms:xml"/>
>        </xforms:model>
>    </head>
>    <body>
>        <xxforms:dialog id="edit-xml-dialog" appearance="full"
> level="modeless" close="true" draggable="true">
>            <xforms:label>Edit XML</xforms:label>
>            <xforms:group ref="instance('xmlfile-instance-copy')">
>                <xforms:textarea ref="metadata"/>
>            </xforms:group>
>            <xxforms:hide ev:event="DOMActivate" dialog="edit-xml-dialog"/>
>            <xforms:setvalue ev:event="xxforms-dialog-open" ref="metadata"
>
> value="saxon:serialize(xxforms:instance('xmlfile-instance'), 'xml')"/>
>        </xxforms:dialog>
>
>        <table class="forms-gridtable">
>            <tr><td><xforms:trigger
> appearance="minimal"><xforms:label>Edit</xforms:label>
>                <xforms:action ev:event="DOMActivate">
>                    <xforms:insert
> context="instance('xmlfile-instance-copy')"
> origin="instance('xmlfile-instance')"/>
>                    <xxforms:show dialog="edit-xml-dialog"/>
>                </xforms:action>
>            </xforms:trigger></td></tr>
>            <tr/><!-- This is to work around a bug in IE -->
>        </table>
>        <widget:xforms-instance-inspector
> xmlns:widget="http://orbeon.org/oxf/xml/widget"/>
>    </body>
> </html>
>
>
> ----- Original Message -----
> From: Erik Bruchez <[hidden email]>
> Date: Monday, November 30, 2009 9:54 pm
> Subject: [ops-users] Re: RE: Displaying Raw XML
>
>> Re #2, I think what you want to do is serialize the instance to obtain
>> text (as the XForms Inspector does). Try something like this:
>>
>> <xforms:output value="saxon:serialize(instance('my-instance'),
>> 'xml')"/>
>> With appropriate CSS, e.g. white-space: pre,  the resulting text
>> should be reasonably formatted.
>>
>> Re #1, you will need to serialize the instance as text into an element
>> or attribute. Then you can edit it in a textarea. Conversely, you will
>> need to use saxon:parse() to convert back the text edited by the user
>> into XML that can then be inserted back into the instance.
>>
>> This is what Form Builder does BTW for the Edit Source feature.
>>
>> -Erik
>>
>> On Wed, Nov 25, 2009 at 8:43 PM, Steven Kerr
>> <[hidden email]> wrote:
>> > Stacy
>> >
>> > I can't see any replies to this question.  I am not an expert on
>> Orbeon,> but the second part of your question should be easy.
>> >
>> > If you place the following code in your page an Orbeon widget
>> will allow
>> > you to view all the instance XML.  You can select the one you
>> want to
>> > view.
>> >
>> > <widget:xforms-instance-inspector
>> > xmlns:widget="http://orbeon.org/oxf/xml/widget"/>
>> >
>> > It might also be possible to customise it.  With regard to
>> editing the
>> > XML, this sounds very possible but I will have to leave that for an
>> > expert to answer.  Alternatively, you could use a separate product.
>> > i.e.
>> > http://www.ephox.com/products/editliveforxml/
>> > But that might be overkill for what you are doing.
>> >
>> > Cheers
>> >
>> > Steve
>> >
>> >
>> > -----Original Message-----
>> > From: stacyladnier [mailto:[hidden email]]
>> > Sent: Friday, 20 November 2009 05:47
>> > To: [hidden email]
>> > Subject: [ops-users] Displaying Raw XML
>> >
>> >
>> > I have a model instance that contains XML of course, we will call it
>> > 'my-instance':
>> >
>> > <myxml>
>> >    <first>
>> >        <second>Data goes here</second>
>> >    </first>
>> > </myxml>
>> >
>> > Further down in the form, I would like to display the contents of
>> the> model in their raw XML format. My users are experience enough
>> with XML
>> > that they like to see the XML format and also sometimes edit the XML
>> > directly. I would like to provide this to them in two different
>> ways and
>> > cannot seem to make it work. I have tried to search for how to do
>> this> but found nothing definitive.
>> >
>> > 1. Textarea containing entire raw XML content, including tags,
>> that a
>> > user can edit and commit back to the db. Committing to the db is
>> > something I will be able to do. I am hung up on getting the raw
>> XML to
>> > display in the textarea.
>> >
>> > 2. A non-editable view of the XML, so basically and HTML page
>> with the
>> > raw contents of the XML displayed within it.
>> >
>> > I apologize if this is a newbie question. I hope it is simple
>> enough to
>> > answer.
>> >
>> > Stacy
>> > --
>> > View this message in context:
>> > http://n4.nabble.com/Displaying-Raw-XML-tp624201p624201.html
>> > Sent from the ObjectWeb OPS - Users mailing list archive at
>> Nabble.com.>
>> >
>> >
>> > --
>> > 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
>> > OW2 mailing lists service home page: http://www.ow2.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
> OW2 mailing lists service home page: http://www.ow2.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
OW2 mailing lists service home page: http://www.ow2.org/wws