Below is the example file
<?xml version='1.0' encoding='UTF-8'?>
<Document xmlns='urn:iso:std:iso:20022:tech:xsd:pain.002.001.02' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<pain.002.001.02>
------------
-------------
-------------
</pain.002.001.02>
</Document>
Below is the XSLT Transformation code :
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sap="http://www.sap.com/sapxsl"
xmlns:asx="http://www.sap.com/abapxml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap version="1.0">
<asx:values>
<xsl:for-each select="Document/pain.002.001.02">
<ACK_HEADER>
<ZTFI_PYSTATUS_HD>
<xsl:for-each select="GrpHdr[1]">
<ORGNLMSG_ID><xsl:value-of select="MsgId"/></ORGNLMSG_ID>
<!-- <MSG_CRTD_DATE><xsl:value-of select="CreDtTm"/></MSG_CRTD_DATE>-->
<xsl:variable name="date_time" select="CreDtTm"/>
<MSG_CRTD_DATE><xsl:value-of select="substring-before(#T,',$date_time')"/></MSG_CRTD_DATE>
<!--Payment Acknowledgement Header data-->
</xsl:for-each>
<xsl:for-each select="OrgnlGrpInfAndSts[1]">
<MSGID><xsl:value-of select="OrgnlMsgId"/></MSGID>
<xsl:variable name="msgid" select="OrgnlMsgId"/>
<ORIGNLMSG_NM_ID><xsl:value-of select="OrgnlMsgNmId"/></ORIGNLMSG_NM_ID>
<ORGNL_NO_OF_TRAN><xsl:value-of select="OrgnlNbOfTxs"/></ORGNL_NO_OF_TRAN>
<ORGNL_CNTRL_SUM><xsl:value-of select="OrgnlCtrlSum"/></ORGNL_CNTRL_SUM>
<ORGNL_FILE_STAT><xsl:value-of select="GrpSts"/></ORGNL_FILE_STAT>
<xsl:for-each select="NbOfTxsPerSts">
<xsl:choose>
<xsl:when test="DtldSts='ACSP'">
<ORGNL_NO_OF_ACSP><xsl:value-of select="DtldNbOfTxs"/></ORGNL_NO_OF_ACSP>
<ORGNL_ACSP_SUM><xsl:value-of select="DtldCtrlSum"/></ORGNL_ACSP_SUM>
</xsl:when>
<xsl:when test="DtldSts='RJCT'">
<ORGNL_NO_OF_RJCT><xsl:value-of select="DtldNbOfTxs"/></ORGNL_NO_OF_RJCT>
<ORGNL_RJCT_SUM><xsl:value-of select="DtldCtrlSum"/></ORGNL_RJCT_SUM>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
</ZTFI_PYSTATUS_HD>
</ACK_HEADER>
<ACK_DETAIL>
<!--Payment Acknowledgement Detail data-->
<xsl:for-each select="TxInfAndSts">
<ZTFI_PYSTATUS_DT>
<MSGID><xsl:value-of select="$msgid"/></MSGID>
<PMT_INFO_IDENT><xsl:value-of select="OrgnlPmtInfId"/></PMT_INFO_IDENT>
<END_2_END_ID><xsl:value-of select="OrgnlEndToEndId"/></END_2_END_ID>
<TRAN_STATUS><xsl:value-of select="TxSts"/></TRAN_STATUS>
<INSTRU_IDENT><xsl:value-of select="OrgnlInstrId"/></INSTRU_IDENT>
<xsl:for-each select="StsRsnInf[1]">
<STAT_RE_AD_INFO><xsl:value-of select="AddtlStsRsnInf"/></STAT_RE_AD_INFO>
</xsl:for-each>
<xsl:for-each select="OrgnlTxRef[1]">
<xsl:for-each select="Amt[1]">
<xsl:for-each select="InstdAmt[1]">
<INSTRCTD_AMT><xsl:value-of select="string()"/></INSTRCTD_AMT>
<CURRENCY><xsl:value-of select="#Ccy"/></CURRENCY>
</xsl:for-each>
</xsl:for-each>
<REQ_EXEC_DATE><xsl:value-of select="ReqdExctnDt"/></REQ_EXEC_DATE>
<xsl:for-each select="CdtrAcct[1]">
<xsl:for-each select="Id[1]">
<xsl:for-each select="PrtryAcct[1]">
<LIFNR><xsl:value-of select="Id"/></LIFNR>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</ZTFI_PYSTATUS_DT>
</xsl:for-each>
</ACK_DETAIL>
</xsl:for-each>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>
when i exclude the following string(in the Document tag) from the XML file i am able to transform.
'xmlns='urn:iso:std:iso:20022:tech:xsd:pain.002.001.02' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
but when i include the same string my XSLT transformation. it is not working.
Please do the needful.
Thanks and Regards,
Kiran.
Add your xml document namespace in your xsl declaration
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sap="http://www.sap.com/sapxsl"
xmlns:asx="http://www.sap.com/abapxml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doc='urn:iso:std:iso:20022:tech:xsd:pain.002.001.02'
>
and refer to your nodes by the prefix doc:. E.g:
<xsl:for-each select="doc:pain.002.001.02">
EDIT
For your problem try:
<xsl:for-each select="doc:Document/doc:pain.002.001.02">
This is a FAQ. XPath treats unprefixed element names as belonging to "no namespace".
Whenever an XML document has a default namespace, the only way to refer to elements by name is to refer to them as prefixed, where the prefix is bound to the default namespace.
This means:
Associate a prefix (say "xxx") to the document's default namespace.
In any XPath expression or match pattern replace every element name by the corresponding preffixed name. For example, replace /a/b/c/d with /xxx:a/xxx:b/xxx:c/xxx:d
After following strictly the above two rules the modified stylesheet behaves as wanted: in the same way as the original stylesheet applied on an XML document that has no default namespace.
Related
I have a large number of xml files with a structure similar to the following, although they are far larger:
<?xml version="1.0" encoding="UTF-8"?>
<a a1="3.0" a2="ABC">
<b b1="P1" b2="123">first
</b>
<b b1="P2" b2="456" b3="xyz">second
</b>
</a>
I want to get the following output:
1|1|b1
1|2|b2
2|1|b1
2|2|b2
2|3|b3
where:
Field 1 is the sequence number for nodes /a/b
Field 2 is the sequence number of the attribute as it appears in the xml file
Field 3 is the attribute name (not value)
I don't quite know how to calculate field 2 correctly.
I've prepared the following xslt file:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<xsl:for-each select="a/b/#*">
<xsl:value-of select="count(../preceding-sibling::*)+1"/>
<xsl:text>|</xsl:text>
<!-- TODO: This is not correct -->
<xsl:value-of select="count(preceding-sibling::*)+1"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
but when I run the following command:
xsltproc a.xslt a.xml > a.csv
I get an incorrect output, as field 2 does not represent the attribute sequence number:
1|1|b1
1|1|b2
2|1|b1
2|1|b2
2|1|b3
Do you have any suggestions on how to get the correct output please?
Please notice that the answers provided in XSLT to order attributes do not provide a solution to this problem.
The order of attributes is irrelevant in XML. For instance, <a a1="3.0" a2="ABC"> and <a a1="3.0" a2="ABC"> are equivalent.
However this specific question is part of a larger application where it is essential to establish the order in which attributes appear in given xml files (and not in xml files that are equivalent to them).
Although, as kjhughes says in comments, attribute order is insignificant. However, you can still select them, and use the position() element to get the numbers you are after (You just can't be sure the order they are output will be the order they appear in the XML, although generally this will be the case).
Try this XSLT. Do note the nested use of xsl:for-each to select only b elements first, to get their position, before getting the attributes, which then have their own separate position.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="/">
<xsl:for-each select="a/b">
<xsl:variable name="bPosition" select="position()"/>
<xsl:for-each select="#*">
<xsl:value-of select="$bPosition"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="position()"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
You could use the position() of the items in the sequence of attributes that you are iterating over and combine with logic for the position of its parent element.
<xsl:template match="/">
<xsl:for-each select="a/b/#*">
<xsl:value-of select="count(../preceding-sibling::*)+1"/>
<xsl:text>|</xsl:text>
<!-- TODO: This is not correct -->
<xsl:value-of select="position() -
(if (count(../preceding-sibling::*)) then count(../preceding-sibling::*)+1 else 0)"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
Which produces the following output:
1|1|b1
1|2|b2
2|1|b1
2|2|b2
2|3|b3
I'm using XML Editor 19.1, Saxon P.E 9.7.
For each selected div, I'm looking to display a graphic/#url, following each <surface> if surface/#xml:id = div/#facs.
XSL
<xsl:for-each select="descendant-or-self::div3[#type='col']/div4[#n]">
<xsl:variable name="div4tablet" select="#facs"/>
<xsl:choose>
<xsl:when test="translate(.[#n]/$div4tablet, '#', '') = preceding::facsimile/surfaceGrp[#type='tablet']/surface[#n]/#xml:id">
<xsl:value-of select=""/> <!-- DISPLAY graphic/#url that follows facsimile/surfaceGrp/surface -->
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
[....]
</xsl:for-each>
TEI example
<facsimile>
<surfaceGrp n="1" type="tablet">
<surface n="1.1" xml:id="ktu1-2_i_1_to_10_img">
<graphic url="../img/KTU-1-2-1-10-recto.jpg"/>
<zone xml:id=""/>
<zone xml:id=""/>
</surface>
<surface n="1.2" xml:id="ktu1-2_i_10_to_30_img">
<graphic url="../img/KTU-1-2-10-30-recto.jpg"/>
<zone xml:id=""/>
</surface>
[...]
</surfaceGrp>
<surfaceGrp n="2">
[...]
</surfaceGrp>
</facsimile>
<text>
[...]
<div3 type="col">
<div4 n="1.2.1-10" xml:id="ktu1-2_i_1_to_10" facs="#ktu1-2_i_1_to_10_img">
[...]
</div4>
<div4 n="1.2.10-30" xml:id="ktu1-2_i_10_to_30" facs="#ktu1-2_i_10_to_30_img">
[...]
</div4>
</div3>
</text>
I have tried <xsl:value-of select="preceding::facsimile/surfaceGrp[#type='tablet']/surface[#n, #xml:id]/graphic/#url"/>, but it displays all graphic/#url and not only the one that follows fascsimile/surfaceGrp/surface.
So my question: how to display only surface/graphic/#url for each div3[#type='col']/div4[#n]?
In advance, thank you for your kind help.
As you use XSLT 2 or 3 and the elements have the xml:id attribute you do not even need a key but can use the id function:
<xsl:template match="div4">
<div>
<xsl:value-of select="id(substring(#facs, 2))/graphic/#url"/>
</div>
</xsl:template>
I put the use of id into a template matching the div4 element but you can of course use it the same way inside of your for-each selecting those elements.
See a minimal but complete sample at https://xsltfiddle.liberty-development.net/bdxtpR.
you should use xsl:key for this type of problem.
First, we must declare a key for the target node
<xsl:key name="kSurface" match="surface" use="concat('#', #xml:id)"/>
notice the concat function being used here, an # was being added to the xml:id so that the keys would appear as:
#ktu1-2_i_1_to_10_img
#ktu1-2_i_10_to_30_img
now in this loop:
<xsl:for-each select="descendant-or-self::div3[#type='col']/div4[#n]">
we can access the key that matches the #facs attribute by having:
<xsl:value-of select="key('kSurface', #facs)/graphic/#url"/>
The whole stylesheet is below:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="1.0">
<xsl:output omit-xml-declaration="yes"/>
<xsl:key name="kSurface" match="surface" use="concat('#', #xml:id)"/>
<xsl:template match="/">
<xsl:for-each select="descendant-or-self::div3[#type='col']/div4[#n]">
<xsl:value-of select="key('kSurface', #facs)/graphic/#url"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
see it in action here.
I must be missing some fundamental concept of processing an XML document. Here is my source XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Root>
<Element>visitorNameAlt</Element>
<Element>visitorScore</Element>
<Element>visitorTimeouts</Element>
<Element>Blank</Element>
<Element>homeNameAlt</Element>
<Element>homeScore</Element>
<Element>homeTimeouts</Element>
<Element>Blank</Element>
<Element>period</Element>
<Element>optionalText</Element>
<Element>flag</Element>
<Element>Blank</Element>
<Element>scoreLogo</Element>
<Element>sponsorLogo</Element>
</Root>
And my XSL stylesheet:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" indent="yes"/>
<xsl:template match="/">
<xsl:for-each select="/Root">
<xsl:value-of select="position()"/>
<xsl:value-of select="Element"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
All I want is to pluck the "Element" names from the source XML doc with their relative position in front.
My output is just "1" followed by the first element and nothing more.
I am new to XSLT, but have processed other documents successfully with for-each.
Thanks in advance.
Bill
You're looping over Root tags, not Element tags. Try this:
<xsl:template match="/">
<xsl:for-each select="/Root/Element">
<xsl:value-of select="position()"/>
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>
Note that you must change the second value-of select to "." or "text()".
XSLT is not an imperative programming language. The XSLT processor grabs each element in turn and tries to match it to your stylesheet. The idiomatic way to write this is without a for-each:
<xsl:template match="/Root">
<xsl:apply-templates select="Element"/>
</xsl:template>
<xsl:template match="Element">
<xsl:value-of select="position()"/>
<xsl:value-of select="."/>
</xsl:template>
The first template matches the root and tells the processor to apply the stylesheet to all the Element nodes inside the Root. The second template matches those nodes, and outputs the desired information.
This is my XML and XSLT code
<root>
<act>
<acts id>123</acts>
</act>
<comp>
<comps id>233</comps>
</comp>
</root>
<xsl:for-each select="act/acts">
<xsl:variable name="contactid" select="#id"/>
<xsl:for-each select="root/comp/comps">
<xsl:variable name="var" select="boolean(contactid=#id)"/>
</xsl:for-each>
<xsl:choose>
<xsl:when test="$var='true'">
. . . do this . . .
</xsl:when>
<xsl:otherwise>
. . . do that . . .
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
I want to dynamically assign true or false to var and use it inside <xsl:choose> for boolean test. I hope this helps to find a better solution to get rid of for-each also
First thing to note is that variables in XSLT are immutable, and cannot be changed once initialised. The main problem with your XSLT is that you define your variable within an xsl:for-each block and so it only exists within the scope of that block. It is not a global variable. A new variable gets defined each time that can only be used within the xsl:for-each
From looking at your XSLT it looks like you want to iterate over the acts element and perform a certain action depending on whether an comps element exists with the same value. An alternative approach would be to define a key to look up the comps elements, like so
<xsl:key name="comps" match="comps" use="#id" />
Then you can simply check whether a comps element exists like so (assuming you are positioned on an acts element.
<xsl:choose>
<xsl:when test="key('comps', #id)">Yes</xsl:when>
<xsl:otherwise>No</xsl:otherwise>
</xsl:choose>
Here is the full XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="comps" match="comps" use="#id" />
<xsl:template match="/root">
<xsl:apply-templates select="act/acts" />
</xsl:template>
<xsl:template match="acts">
<xsl:choose>
<xsl:when test="key('comps', #id)"><res>Yes</res></xsl:when>
<xsl:otherwise><res>No</res></xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
When applied to the following (well-formed) XML
<root>
<act>
<acts id="123"/>
</act>
<comp>
<comps id="233"/>
</comp>
</root>
The following is output
No
However, it can often be preferably in XSLT to avoid the use of conditional statements like xsl:choose and xsl:if. Instead, you can structure the XSLT to make use of template matching. Here is the alternate approach
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="comps" match="comps" use="#id" />
<xsl:template match="/root">
<xsl:apply-templates select="act/acts" />
</xsl:template>
<xsl:template match="acts[key('comps', #id)]">
<res>Yes</res>
</xsl:template>
<xsl:template match="acts">
<res>No</res>
</xsl:template>
</xsl:stylesheet>
When applied to the same XML, the same result is output. Do note the more specific template for the acts node will take priority when matching the case where a comps exist.
There are some errors in your xml file, but assuming what you mean is:
<root>
<act><acts id="123"></acts></act>
<comp><comps id="233"></comps></comp>
</root>
Here is a full solution:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<doc>
<xsl:apply-templates select="root/comp/comps"/>
</doc>
</xsl:template>
<xsl:template match="root/comp/comps">
<xsl:variable name="compsid" select="#id"></xsl:variable>
<xsl:choose>
<xsl:when test="count(/root/act/acts[#id=$compsid])>0">Do This</xsl:when>
<xsl:otherwise>Do That</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
I have some XML of the form:
<definitions devices="myDevice">
<reg offset="0x0000" mnem="someRegister">
<field mnem="someField" msb="31" lsb="24 />
...
</reg>
...
</definitions>
I want the XML to be the definitive reference and use XSLT to transform it to HTML for documentation, .h for building (and maybe other forms too).
The HTML version is working fine and produces a table per register, with a row per field:
... (header boilerplate removed)
<xsl:for-each select="definitions/reg">
<table>
<tr>
<th><xsl:value-of select="#offset"/></th>
<th><xsl:value-of select="#mnem"/></th>
</tr>
<xsl:for-each select="field">
<tr>
<td><xsl:value-of select="#msb"/>..<xsl:value-of select="#lsb"/></td>
<td><xsl:value-of select="#mnem"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:for-each>
Converting to a .h isn't going so well. I'm completely failing to generate the required spaces in the output:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="definitions/reg">
#define <xsl:value-of select="translate(#mnem,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
<xsl:text> </xsl:text>
<xsl:value-of select="#offset"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I'd hope for that to produce the output:
#define SOMEREGISTER 0x0000
But I actually get:
#define SOMEREGISTER0x0000
I don't understand why I get the space after the '#define', but not the one after the transformed mnemonic. I've tried a simpler solution with just an inline space, with the same results.
I'm too new to this (XSLT) to know whether I'm a) doing it wrong or b) finding a limitation in tDOM.
Testing with this:
# I could have read these from a file I suppose...
set in {<definitions devices="myDevice">
<reg offset="0x0000" mnem="someRegister">
<field mnem="someField" msb="31" lsb="24" />
</reg>
</definitions>}
set ss {<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="definitions/reg">
<xsl:text>#define </xsl:text>
<xsl:value-of select="translate(#mnem,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
<xsl:text xml:space="preserve"> </xsl:text>
<xsl:value-of select="#offset"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>}
# Interesting code starts here
package require tdom
set indoc [dom parse $in]
set xslt [dom parse -keepEmpties $ss]
set outdoc [$indoc xslt $xslt]
puts [$outdoc asText]
I find that this works. The issue is that the tDOM parser doesn't handle the xml:space attribute correctly; without the magical -keepEmpties option, all the empty strings are stripped from the stylesheet and that leads to a wrong XSLT stylesheet being applied. But with the option, it appears to do the right thing.
Note that the XSLT engine itself is doing the right thing. It's the XML parser/DOM builder. (I think it's a bug; I'll look up where to report it.)
Per:
http://www.ibm.com/developerworks/xml/library/x-tipwhitesp/index.html
Try using the preserve space directive:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="definitions/reg">
<xsl:text xml:space="preserve">#define </xsl:text>
<xsl:value-of select="translate(#mnem,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
<xsl:text xml:space="preserve"> </xsl:text>
<xsl:value-of select="#offset"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
You don't have an output method specified in your second stylesheet, so the default is gonna be XML. I'd advice you to use output method "text", then use <xsl:text> elements for any literal output. Check this example:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="/">
<xsl:for-each select="definitions/reg"><xsl:text>#define </xsl:text><xsl:value-of select="translate(#mnem,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/><xsl:text> </xsl:text><xsl:value-of select="#offset"/><xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
EDIT: by the way, that
at the end is a character code. It's simply the decimal value of the ASCII code for a line feed. This makes sure you start a new line for the next reg entry. If you need the Windows/DOS convention (carriage return + line feed), use
instead.