2

I'm newbie in XSL and XML. I tried to make a table which contain Name and ID that can generate into html file, but when I try to run it there's no output.

Here's my xml code:

  <Column Description="POS Name"/>

  <Column Description="POS ID"/>

</Columns>

<Row>

  <POS Name>Mall 1</POS Name>

  <POS ID>00001</POS ID>

</Row>

<Row>

  <POS Name>Mall 2</POS Name>

  <POS ID>00002</POS ID>

</Row>

<Row>
  <POS Name>Mall 3</POS Name>

  <POS ID>00003</POS ID>

</Row>

And here's my xsl code:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://homecredit.net/homerselect/ws/incomingPayments/dto" version="1.0">
   <xsl:output method="html" indent="yes" standalone="yes" />
   <xsl:template match="/">
      <xsl:element name="POS">
         <xsl:attribute name="lang">en</xsl:attribute>
         <xsl:element name="head">
            <xsl:element name="title">POS</xsl:element>
         </xsl:element>
         <xsl:element name="table">
            <xsl:attribute name="border">1</xsl:attribute>
            <xsl:element name="tr">
               <xsl:element name="th">POS NAME</xsl:element>
               <xsl:element name="th">POS ID</xsl:element>
            </xsl:element>
            <xsl:element name="tr">
               <xsl:element name="td">Mall</xsl:element>
               <xsl:element name="td">00001</xsl:element>
            </xsl:element>
            <xsl:element name="tr">
               <xsl:element name="td">Mall 2</xsl:element>
               <xsl:element name="td">00002</xsl:element>
            </xsl:element>
            <xsl:element name="tr">
               <xsl:element name="td">Mall 3</xsl:element>
               <xsl:element name="td">00003</xsl:element>
            </xsl:element>
         </xsl:element>
      </xsl:element>
   </xsl:template>
</xsl:stylesheet>

The final output that I need is like this

POS Name                 POS ID
Mall                     00001
Mall 2                   00002
Mall 3                   00003
5
  • How are you actually 'running' your XSLT, and where are you expecting it to be output? Commented Nov 7, 2013 at 8:35
  • And what is your input xml file. The xslt "expects" an xml containing a POS tag with lang, head attrs etc. Commented Nov 7, 2013 at 8:37
  • My expected output is like this Column 1 contains POS name under POS name are Mall, Mall 2, Mall 3 while column 2 contains POS ID under POS ID are 00001, 00002, 00003 Commented Nov 7, 2013 at 9:15
  • Rephrasing Tim C's questions. What application are you using to execute the XSLT? Commented Nov 8, 2013 at 2:02
  • I'm using wnscp as server Commented Nov 8, 2013 at 5:12

1 Answer 1

2

See http://zvon.org/xxl/XSLTutorial/Output/

XSLT is used to transform one XML doc into another. For this it matches portions of input and sends selected portions to the output, operating on them if needed.

If you have no input, use a dummy file containing <dummy/> and the following xslt for starters :-

<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <head>
        <title>POS</title>
        </head>
        <table>
        </table>
    </xsl:template>
</xsl:stylesheet>

On my unix based system this gives :-

% xsltproc test.xslt in.xml 
<?xml version="1.0"?>
<head><title>POS</title></head><table/>
Sign up to request clarification or add additional context in comments.

1 Comment

I need output like this POS Name POS ID Mall 00001 Mall 2 00002 Mall 3 00003

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.