Xhtml format? - InfoPath Dev
in

InfoPath Dev

Xhtml format?

Last post 09-19-2007 09:18 AM by Greg Collins. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 02-08-2007 09:48 PM

    Xhtml format?

    Hi all,

    I've been trying to add a repetitive rich formatted textbox in infopath form using jscript.

    I have formatted the textbox to Rich Formatted (XHTML) but for some reason, i cant put any XHTML code when I tried to add new value for the text box. Infopath interprets it as pure text, I can not even add a new line.

    I have tried \n, <br />, <br> :( Does anyone have any idea about this?
  • 02-09-2007 12:36 PM In reply to

    You cannot simple assign a text value, like other fields, to a rich text box and expect HTML to come out the other side. Text is text is text. You need to build an XHTML DOM (note that Rich Text has a special namespace that it expects to be used on every top level node which you can find by creating a sample app and saving an XML file with Rich Text). Once you have built your XHTML DOM, you can insert/append it to the rich text node.
  • 02-11-2007 05:10 PM In reply to

    Thanks for your answer, Greg.

    So what I need to do?

    I have tried creating a new node by referencing to that namespace..
    Well it's a text node with an xhtml formatted:

    something that begins with:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    I have validated the xhtml and it is valid.

    Then I create valid xhtml and tried attaching it. However, infopath shows all the xhtml tags and no formatting at all.

    I've also tried mimicking how infopath creates newline (ie.<div xmlns="http://www.w3.org/1999/xhtml">test</div>
    Put them in my script and attaching it on the node. However, it displays the whole tag and no newline :(

    So confused..
  • 02-13-2007 04:59 PM In reply to

    So are you trying to set the "value" of the rich text field, or append new nodes to the rich text field.. that's where I think the key difference is.

    i.e. thisXDocument.DOM.selectSingleNode("myRichTextField").text = "<div xmlns=\"http://www.w3.org/1999/xhtml\">test</div>"; will only give you the text.

    You need to create a new node from that xhtml and do an appendChild(newNode) to the rich text field.
  • 09-14-2007 06:47 AM In reply to

    I am confused too, have u a exemple to get only "test" ?

  • 09-14-2007 10:35 AM In reply to

    The previous discussion was about setting an XHTML value. Are you asking about how to get just the text of an XHTML node? If you want just the text, and not all the nodes, just access the .text property.

  • 09-17-2007 04:50 AM In reply to

    With .text I am getting the DIVs tags too...

  • 09-17-2007 07:54 AM In reply to

    I have this in XML:

     <my:Orientacoes xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-04-25T20:30:37"><h3 style="PADDING-RIGHT: 0cm; MARGIN-TOP: 18pt; PADDING-LEFT: 0cm; FONT-WEIGHT: normal; MARGIN-BOTTOM: 12pt; LINE-HEIGHT: 150%" align="justify" xmlns="http://www.w3.org/1999/xhtml"><strong><font color="#000000" size="2">Validade</font></strong></h3> <ul style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" type="disc" xmlns="http://www.w3.org/1999/xhtml"> <li style="PADDING-RIGHT: 0cm; MARGIN-TOP: 0cm; MARGIN-BOTTOM: 0pt; TEXT-INDENT: -18pt; LINE-HEIGHT: 150%" align="justify">Negativa do Ministério da Fazenda e Procuradoria-Geral da Fazenda Nacional - Secretaria da Receita Federal – 180 dias;</li> <li style="PADDING-RIGHT: 0cm; MARGIN-TOP: 0cm; MARGIN-BOTTOM: 0pt; TEXT-INDENT: -18pt; LINE-HEIGHT: 150%" align="justify">Negativa da Secretaria da Fazenda Receita Estadual – 90 dias;</li> <li style="PADDING-RIGHT: 0cm; MARGIN-TOP: 0cm; MARGIN-BOTTOM: 0pt; TEXT-INDENT: -18pt; LINE-HEIGHT: 150%" align="justify">Negativa da Secretaria Municipal da Fazenda – 180 dias;</li> <li style="PADDING-RIGHT: 0cm; MARGIN-TOP: 0cm; MARGIN-BOTTOM: 0pt; TEXT-INDENT: -18pt; LINE-HEIGHT: 150%" align="justify">Negativa da Previdência Social – 180 dias;</li> <li style="PADDING-RIGHT: 0cm; MARGIN-TOP: 0cm; MARGIN-BOTTOM: 0pt; TEXT-INDENT: -18pt; LINE-HEIGHT: 150%" align="justify">Negativa do Certificado de Regularidade FGTS – CRF – 30 dias.</li></ul> <h3 style="PADDING-RIGHT: 0cm; MARGIN-TOP: 18pt; PADDING-LEFT: 0cm; FONT-WEIGHT: normal; MARGIN-BOTTOM: 12pt; LINE-HEIGHT: 150%" align="justify" xmlns="http://www.w3.org/1999/xhtml"><strong><font color="#000000" size="2">Prazo</font></strong></h3> <div style="PADDING-RIGHT: 0cm; MARGIN-TOP: 0cm; PADDING-LEFT: 0cm; MARGIN-BOTTOM: 0pt; LINE-HEIGHT: 150%" align="justify" xmlns="http://www.w3.org/1999/xhtml">     As Unidades Acadêmicas, Faculdades e Departamentos deverão solicitar com prazo de uma semana.</div></my:Orientacoes>

     

    But I want to show this:

    Validade

    • Negativa do Ministério da Fazenda e Procuradoria-Geral da Fazenda Nacional - Secretaria da Receita Federal – 180 dias;
    • Negativa da Secretaria da Fazenda Receita Estadual – 90 dias;
    • Negativa da Secretaria Municipal da Fazenda – 180 dias;
    • Negativa da Previdência Social – 180 dias;
    • Negativa do Certificado de Regularidade FGTS – CRF – 30 dias.

    Prazo

         As Unidades Acadêmicas, Faculdades e Departamentos deverão solicitar com prazo de uma semana.
     
     
     
    But I don´t have sucess, all that tags are displayed not the text
  • 09-17-2007 11:06 PM In reply to

    Hi I know what you wanna do and it is really simple :) once you know the trick. Here a little walkthrough: Create a new blank infoapth form. drop a rich text box into it. publish it and fill out the form once, add a bulleted list into your richtext box and enter as text "test1". save the filled out form to your desktop. now open the form again in design mode and extract your form file. open the previous filled out form with the nodepad and copy the bulleted list presentation e.g. li xmlns="http://www.w3.org/1999/xhtml"test1 /li, navigate to the folder to which you extracted your form files. open the the template.xml with the notepad and add the copied line to your richtext box field, e.ge field1 li xmlns="http://www.w3.org/1999/xhtml" test1/li /field1. now right click the manifest file and select design. resave the form. there you go. hope this helps. BTW don't forget the <> for the tags, if I put them there I get a bullet list, weired uh :)
    Listen to Motörhead cos they play Rock'n Roll :)
  • 09-19-2007 05:21 AM In reply to

    Thanks nukkumatti,

    but I need to this with other mode, since the bulleted text (and all the formatted text) come from a webservice...

  • 09-19-2007 09:18 AM In reply to

    The problem is that the .text property ONLY gives text. That's why they named it that.

    What you want is rich text, or XHTML. To display rich text, you need a rich text control.

    To copy XHTML from one field to another, you cannot simpy use .text or you will get all the tags, etc., as you have already seen.

    XHTML is a DOM. You must use code to copy the DOM nodes from one field to another -- accounting for namespace changes if appropriate.

    There is no built-in functionality for copying XHTML data from one field to another. You will have to write one yourself.

Page 1 of 1 (11 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.