Quantcast

xforms show XML in textarea

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

xforms show XML in textarea

Alfredo Cosco
Hello,
I'm using exist 2.2 and I'm working with betterForm to edit my documents.

So my documents are like this:

<mydoc>
    <title>Title</title>
   <doc>
       Content of the document that <example>shall</example> be marked
    </doc>
</mydoc>

Now I would linke to show a textarea with the content of the <doc> element as it is, with all the XML tags because my users have to be able to edit direcly XML.

So, if I do something like this:
            <xf:textarea id="doc" ref="//doc" incremental="true">
                <xf:label>XPROT</xf:label>
                <xf:hint>a Hint for this control</xf:hint>
                <xf:help>help for textarea1</xf:help>
                <xf:alert>invalid</xf:alert>
            </xf:textarea>

the result is an empty textarea

If I do like this: 
         <xf:textarea id="doc" ref="//doc/*" incremental="true">

the result is a textarea with only the content of <example> element: "shall"

If I do like this:
         <xf:textarea id="doc" ref="//doc/text()" incremental="true">
the result is a textarea with only the content of the <doc> element before the <example> element:  "Content of the document that"

How can I show the entire content of <doc> without stripping the tags? 

Thank you,
Alfredo


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

Re: xforms show XML in textarea

Ari Nordström
Hi Alfredo,

I'd bind the document to an instance and use xf:output to display the instance. Something like this should display the tags, although more might be needed to pretty-print:

<xf:output value="serialize(instance('doc'),'yes')">
    <xf:label>My document: </xf:label>
</xf:output>

I've used this sort of thing in the past for debugging my XForms.

Best,

/Ari


On 23 February 2017 at 19:21, Alfredo Cosco <[hidden email]> wrote:
Hello,
I'm using exist 2.2 and I'm working with betterForm to edit my documents.

So my documents are like this:

<mydoc>
    <title>Title</title>
   <doc>
       Content of the document that <example>shall</example> be marked
    </doc>
</mydoc>

Now I would linke to show a textarea with the content of the <doc> element as it is, with all the XML tags because my users have to be able to edit direcly XML.

So, if I do something like this:
            <xf:textarea id="doc" ref="//doc" incremental="true">
                <xf:label>XPROT</xf:label>
                <xf:hint>a Hint for this control</xf:hint>
                <xf:help>help for textarea1</xf:help>
                <xf:alert>invalid</xf:alert>
            </xf:textarea>

the result is an empty textarea

If I do like this: 
         <xf:textarea id="doc" ref="//doc/*" incremental="true">

the result is a textarea with only the content of <example> element: "shall"

If I do like this:
         <xf:textarea id="doc" ref="//doc/text()" incremental="true">
the result is a textarea with only the content of the <doc> element before the <example> element:  "Content of the document that"

How can I show the entire content of <doc> without stripping the tags? 

Thank you,
Alfredo


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open



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

Re: xforms show XML in textarea

Alfredo Cosco
Hi Ari,
thanks for your reply. 
I found a way, but after a couple of weeks with xforms I realized that, in my case and imho, they do nothing more that I can do with some js lines and/or xquery functions. 
Moreover, their online documentation is poor and often not very consistent, so I decided not to use them in my project.

Regards,
Alfredo


2017-02-28 13:46 GMT+01:00 Ari Nordström <[hidden email]>:
Hi Alfredo,

I'd bind the document to an instance and use xf:output to display the instance. Something like this should display the tags, although more might be needed to pretty-print:

<xf:output value="serialize(instance('doc'),'yes')">
    <xf:label>My document: </xf:label>
</xf:output>

I've used this sort of thing in the past for debugging my XForms.

Best,

/Ari


On 23 February 2017 at 19:21, Alfredo Cosco <[hidden email]> wrote:
Hello,
I'm using exist 2.2 and I'm working with betterForm to edit my documents.

So my documents are like this:

<mydoc>
    <title>Title</title>
   <doc>
       Content of the document that <example>shall</example> be marked
    </doc>
</mydoc>

Now I would linke to show a textarea with the content of the <doc> element as it is, with all the XML tags because my users have to be able to edit direcly XML.

So, if I do something like this:
            <xf:textarea id="doc" ref="//doc" incremental="true">
                <xf:label>XPROT</xf:label>
                <xf:hint>a Hint for this control</xf:hint>
                <xf:help>help for textarea1</xf:help>
                <xf:alert>invalid</xf:alert>
            </xf:textarea>

the result is an empty textarea

If I do like this: 
         <xf:textarea id="doc" ref="//doc/*" incremental="true">

the result is a textarea with only the content of <example> element: "shall"

If I do like this:
         <xf:textarea id="doc" ref="//doc/text()" incremental="true">
the result is a textarea with only the content of the <doc> element before the <example> element:  "Content of the document that"

How can I show the entire content of <doc> without stripping the tags? 

Thank you,
Alfredo


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open




------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Loading...