Generating new line inside of Generate Data operator

robin
robin New Altair Community Member
edited November 2024 in Community Q&A
We currently generate text that is parsed into an XML for third party software. This software does not follow the conventions for line breaks and utilised the characters inside of the text field to split the lines.

We need to generate the following:

Get what 
you want

When using the generate data operator and then the extract document operator the above gets turned into:

Get what  you want

(There are two spaces (Hex: 20 20) instead of a line break (Hex: 0D 0A))

How do I correctly generate the line break using this operator?

<?xml version="1.0" encoding="UTF-8"?><process version="8.2.000">
  <operator activated="true" class="generate_data_user_specification" compatibility="8.2.000" expanded="true" height="68" name="Generate Data by User Specification" width="90" x="715" y="595">
    <list key="attribute_values">
      <parameter key="1" value="(&quot;Get what you want&quot;)"/>
    </list>
    <list key="set_additional_roles"/>
  </operator>
</process>


Tagged:

Best Answers

  • sgenzer
    sgenzer
    Altair Employee
    Answer ✓
    how about this?

    <?xml version="1.0" encoding="UTF-8"?><process version="9.2.000">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="9.2.000" expanded="true" name="Process">
        <parameter key="logverbosity" value="init"/>
        <parameter key="random_seed" value="2001"/>
        <parameter key="send_mail" value="never"/>
        <parameter key="notification_email" value=""/>
        <parameter key="process_duration_for_mail" value="30"/>
        <parameter key="encoding" value="SYSTEM"/>
        <process expanded="true">
          <operator activated="true" class="text:create_document" compatibility="8.1.000" expanded="true" height="68" name="Create Document" width="90" x="45" y="34">
            <parameter key="text" value="Get what  you want"/>
            <parameter key="add label" value="false"/>
            <parameter key="label_type" value="nominal"/>
          </operator>
          <operator activated="true" class="text:documents_to_data" compatibility="8.1.000" expanded="true" height="82" name="Documents to Data" width="90" x="179" y="34">
            <parameter key="text_attribute" value="text"/>
            <parameter key="add_meta_information" value="false"/>
            <parameter key="datamanagement" value="double_sparse_array"/>
            <parameter key="data_management" value="auto"/>
          </operator>
          <operator activated="true" class="web:encode_urls" compatibility="9.0.000" expanded="true" height="82" name="Encode URLs" width="90" x="313" y="34">
            <parameter key="url_attribute" value="text"/>
            <parameter key="encoding" value="SYSTEM"/>
          </operator>
          <operator activated="true" class="replace" compatibility="9.2.000" expanded="true" height="82" name="Replace" width="90" x="447" y="34">
            <parameter key="attribute_filter_type" value="single"/>
            <parameter key="attribute" value="text"/>
            <parameter key="attributes" value=""/>
            <parameter key="use_except_expression" value="false"/>
            <parameter key="value_type" value="nominal"/>
            <parameter key="use_value_type_exception" value="false"/>
            <parameter key="except_value_type" value="file_path"/>
            <parameter key="block_type" value="single_value"/>
            <parameter key="use_block_type_exception" value="false"/>
            <parameter key="except_block_type" value="single_value"/>
            <parameter key="invert_selection" value="false"/>
            <parameter key="include_special_attributes" value="false"/>
            <parameter key="replace_what" value="[+][+]"/>
            <parameter key="replace_by" value="%0D%0A"/>
          </operator>
          <operator activated="true" class="web:decode_urls" compatibility="9.0.000" expanded="true" height="82" name="Decode URLs" width="90" x="581" y="34">
            <parameter key="url_attribute" value="text"/>
            <parameter key="encoding" value="SYSTEM"/>
          </operator>
          <operator activated="true" class="text:data_to_documents" compatibility="8.1.000" expanded="true" height="68" name="Data to Documents" width="90" x="715" y="34">
            <parameter key="select_attributes_and_weights" value="false"/>
            <list key="specify_weights"/>
          </operator>
          <operator activated="true" class="text:combine_documents" compatibility="8.1.000" expanded="true" height="82" name="Combine Documents" width="90" x="849" y="34"/>
          <connect from_op="Create Document" from_port="output" to_op="Documents to Data" to_port="documents 1"/>
          <connect from_op="Documents to Data" from_port="example set" to_op="Encode URLs" to_port="example set input"/>
          <connect from_op="Encode URLs" from_port="example set output" to_op="Replace" to_port="example set input"/>
          <connect from_op="Replace" from_port="example set output" to_op="Decode URLs" to_port="example set input"/>
          <connect from_op="Decode URLs" from_port="example set output" to_op="Data to Documents" to_port="example set"/>
          <connect from_op="Data to Documents" from_port="documents" to_op="Combine Documents" to_port="documents 1"/>
          <connect from_op="Combine Documents" from_port="document" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>

Answers

  • robin
    robin New Altair Community Member
    What I have been doing to date is going into the XML and changing the #10 to a #13 but that is not tenable when running on server. 
  • sgenzer
    sgenzer
    Altair Employee
    Answer ✓
    how about this?

    <?xml version="1.0" encoding="UTF-8"?><process version="9.2.000">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="9.2.000" expanded="true" name="Process">
        <parameter key="logverbosity" value="init"/>
        <parameter key="random_seed" value="2001"/>
        <parameter key="send_mail" value="never"/>
        <parameter key="notification_email" value=""/>
        <parameter key="process_duration_for_mail" value="30"/>
        <parameter key="encoding" value="SYSTEM"/>
        <process expanded="true">
          <operator activated="true" class="text:create_document" compatibility="8.1.000" expanded="true" height="68" name="Create Document" width="90" x="45" y="34">
            <parameter key="text" value="Get what  you want"/>
            <parameter key="add label" value="false"/>
            <parameter key="label_type" value="nominal"/>
          </operator>
          <operator activated="true" class="text:documents_to_data" compatibility="8.1.000" expanded="true" height="82" name="Documents to Data" width="90" x="179" y="34">
            <parameter key="text_attribute" value="text"/>
            <parameter key="add_meta_information" value="false"/>
            <parameter key="datamanagement" value="double_sparse_array"/>
            <parameter key="data_management" value="auto"/>
          </operator>
          <operator activated="true" class="web:encode_urls" compatibility="9.0.000" expanded="true" height="82" name="Encode URLs" width="90" x="313" y="34">
            <parameter key="url_attribute" value="text"/>
            <parameter key="encoding" value="SYSTEM"/>
          </operator>
          <operator activated="true" class="replace" compatibility="9.2.000" expanded="true" height="82" name="Replace" width="90" x="447" y="34">
            <parameter key="attribute_filter_type" value="single"/>
            <parameter key="attribute" value="text"/>
            <parameter key="attributes" value=""/>
            <parameter key="use_except_expression" value="false"/>
            <parameter key="value_type" value="nominal"/>
            <parameter key="use_value_type_exception" value="false"/>
            <parameter key="except_value_type" value="file_path"/>
            <parameter key="block_type" value="single_value"/>
            <parameter key="use_block_type_exception" value="false"/>
            <parameter key="except_block_type" value="single_value"/>
            <parameter key="invert_selection" value="false"/>
            <parameter key="include_special_attributes" value="false"/>
            <parameter key="replace_what" value="[+][+]"/>
            <parameter key="replace_by" value="%0D%0A"/>
          </operator>
          <operator activated="true" class="web:decode_urls" compatibility="9.0.000" expanded="true" height="82" name="Decode URLs" width="90" x="581" y="34">
            <parameter key="url_attribute" value="text"/>
            <parameter key="encoding" value="SYSTEM"/>
          </operator>
          <operator activated="true" class="text:data_to_documents" compatibility="8.1.000" expanded="true" height="68" name="Data to Documents" width="90" x="715" y="34">
            <parameter key="select_attributes_and_weights" value="false"/>
            <list key="specify_weights"/>
          </operator>
          <operator activated="true" class="text:combine_documents" compatibility="8.1.000" expanded="true" height="82" name="Combine Documents" width="90" x="849" y="34"/>
          <connect from_op="Create Document" from_port="output" to_op="Documents to Data" to_port="documents 1"/>
          <connect from_op="Documents to Data" from_port="example set" to_op="Encode URLs" to_port="example set input"/>
          <connect from_op="Encode URLs" from_port="example set output" to_op="Replace" to_port="example set input"/>
          <connect from_op="Replace" from_port="example set output" to_op="Decode URLs" to_port="example set input"/>
          <connect from_op="Decode URLs" from_port="example set output" to_op="Data to Documents" to_port="example set"/>
          <connect from_op="Data to Documents" from_port="documents" to_op="Combine Documents" to_port="documents 1"/>
          <connect from_op="Combine Documents" from_port="document" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>
  • robin
    robin New Altair Community Member
    Yip @sgenzer that works, very convoluted though, would have thought there was an easier way to accommodate CR and LF.

    Thank you
  • sgenzer
    sgenzer
    Altair Employee
    there is a very fine line between convoluted and clever :wink: