Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3981040
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:21:45+00:00 2026-05-20T05:21:45+00:00

HI all, I should to generate this xml file: <document> <line id=0> <field id=0><![CDATA[MAR5555]]></field>

  • 0

HI all,

I should to generate this xml file:

<document>
    <line id="0">
        <field id="0"><![CDATA[MAR5555]]></field>
        <field id="1"><![CDATA[something]]></field>
        <field id="2"><![CDATA[something]]></field>
        <field id="3"><![CDATA[something12123]]></field>
        <field id="4"/>
        <field id="5"/>
        <field id="6"/>
        <field id="7"/>
        <field id="8"/>
        <field id="9"/>
        <field id="10"/>
        <field id="11"/>
        <field id="12"/>
        <field id="13"/>
        <field id="14"/>
        <field id="15"/>
        <field id="16"/>
        <field id="17"><![CDATA[0072972+1313113123123]]></field>
        <field id="18"><![CDATA[5353]]></field>
        <field id="19"><![CDATA[444432323]]></field>
        <field id="20"/>
        <field id="21"/>
    </line>
    <line id="1">
        <field id="0"><![CDATA[MAR6435]]></field>
        <field id="1"><![CDATA[car123]]></field>
        <field id="2"><![CDATA[sds]]></field>
        <field id="3"><![CDATA[fest]]></field>
        <field id="4"/>
        <field id="5"/>
        <field id="6"/>
        <field id="7"/>
        <field id="8"/>
        <field id="9"/>
        <field id="10"/>
        <field id="11"/>
        <field id="12"/>
        <field id="13"/>
        <field id="14"/>
        <field id="15"><![CDATA[0000062+0dadasd]]></field>
        <field id="16"><![CDATA[032]]></field>
        <field id="17"><![CDATA[23242442]]></field>
        <field id="18"/>
        <field id="19"><![CDATA[000000]]></field>
        <field id="20"/>
        <field id="21"/>
    </line>
    <line id="2">
        <field id="0"><![CDATA[MAR6435]]></field>
        <field id="1"><![CDATA[sss]]></field>
        <field id="2"><![CDATA[Something111]]></field>
        <field id="3"><![CDATA[something111]]></field>
        <field id="4"/>
        <field id="5"/>
        <field id="6"/>
        <field id="7"/>
        <field id="8"/>
        <field id="9"/>
        <field id="10"/>
        <field id="11"/>
        <field id="12"/>
        <field id="13"/>
        <field id="14"/>
        <field id="15"><![CDATA[0000062+0sdsd]]></field>
        <field id="16"><![CDATA[022]]></field>
        <field id="17"><![CDATA[23444444]]></field>
        <field id="18"/>
        <field id="19"><![CDATA[000000]]></field>
        <field id="20"/>
        <field id="21"/>
    </line>
</document>

My programs looks:

<xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:key name="kLine" match="line" use="substring-before(field[contains(., '+')],'+')"/>
    <xsl:template match="/*">
        <document>
         <xsl:apply-templates select="line[contains(field[@id='0'], 'MAR')][count( . | key('kLine',substring-before(field[contains(., '+')],'+'))[1]) = 1]"/>
        </document>
    </xsl:template>
    <xsl:template match="line">
      <type-MAR>
       <document>
        <xsl:value-of select="substring-before(field[contains(., '+')],'+')"/> 
       </document>
        <!--     For each document-->
        <line>
         <LineNumber>
          <xsl:value-of select="position()"/>
         </LineNumber>
         <LineItem>
           <xsl:value-of select="'should be fielled number of after two fields which contain symbol + '"/>
         </LineItem>
        </line>
        <!-- For each document-->
       </type-MAR>
        </xsl:template>
</xsl:stylesheet>

I’m stuck, taking LineItem number after field id which contains symbol ‘+’. for example if I know that ‘field id = 17’ has + symbol, when after two rows I will have LineItem and do calculating I mean if ‘field id = 17’ when ‘field id = 17+2’, if ‘field id = 16’ then ‘field id = 18’ and so on. but now when field with symbol ‘+’ are not defining, I can’t to do it. Also if I use ‘key’, i want to ask how to use correct cycle “for each”, to calculate number of lines. Result should be:

<document>
    <type-MAR>
        <document>0072972</document>
        <line>
            <LineNumber>1</LineNumber>
            <LineItem>444432323</LineItem>
        </line>
    </type-MAR>
    <type-MAR>
        <document>0000062</document>
        <line>
            <LineNumber>1</LineNumber>
            <LineItem>23242442</LineItem>
            <LineNumber>2</LineNumber>
            <LineItem>23444444</LineItem>
        </line>
    </type-MAR>
</document>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:21:46+00:00Added an answer on May 20, 2026 at 5:21 am

    I solve it by self. maybe my question was not clearly.
    first off all to found path to field after document number I use Following sibling. to select all needed LineItem I use “variable name”, finally program looks:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
        <xsl:key name="kLine" match="line" use="substring-before(field[contains(., '+')],'+')"/>
        <xsl:template match="/*">
            <document>
                <xsl:apply-templates select="line[contains(field[@id='0'], 'MAR')][count( . | key('kLine',substring-before(field[contains(., '+')],'+'))[1]) = 1]"/>
            </document>
        </xsl:template>
        <xsl:template match="line">
        <xsl:variable name="doc_code" select="substring-before(field[contains(., '+')],'+')"/>
            <type-MAR>
                <document>
                    <xsl:value-of select="substring-before(field[contains(., '+')],'+')"/>
                </document>
                <xsl:for-each select="//line[substring-before(field[contains(., '+')],'+')=$doc_code]">
                                <line>
                        <LineNumber>
                            <xsl:value-of select="position()"/>
                        </LineNumber>
                        <LineItem>
                        <xsl:value-of select="field[contains(., '+')]/following-sibling::field[2]"/>
                        </LineItem>
                    </line>
                </xsl:for-each>
            </type-MAR>
        </xsl:template>
    </xsl:stylesheet>
    

    Best regards

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this very simple CODE, which should generate me HTML, but all I
Should all structs and classes be declared in the header file? If I declare
All Gmail users should have already noticed that file upload progress bar has been
I'm using a PHP file to output an XML Document. I'm using a CSS
I have tried all that i could to generate the R.java file but in
Does anyone know of an app that would generate an xml file filled out
I am using spreadsheet gem to generate native Excel file. This is not CSV,
try.pl is a script that is trying to generate sample.xml which should validate against
To give you an example that you all should be familiar with, imagine that
I need to update more than one update statements, but all should work on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.