logo
down
shadow

Need help to create an XSLT


Need help to create an XSLT

By : user2952565
Date : November 19 2020, 01:01 AM
I wish this help you I have a XML file which was generated from a SQL table. And I need to transform the XML into my desired output XML. , To sort this XML, you can use Muenchian Grouping. Following XSLT
code :
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
  <xsl:key name="prodId" match="row" use="aaa" />
  <xsl:template match="rowset">
    <xsl:for-each select="row[generate-id() =
            generate-id(key('prodId', aaa)[1])]"> 
      <product product-id = "{aaa}">
        <Name><xsl:value-of select="bbb"/></Name> 
        <xsl:for-each select="key('prodId', aaa)">
          <Image>
            <xsl:attribute name="image-view-type" select="ddd[1]"/>
            <xsl:attribute name="image-color" select="eee"/>
          </Image>
        </xsl:for-each>
        <DeptCode><xsl:value-of select="ddd[2]"/></DeptCode>
      </product>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>
<product product-id="123">
  <Name>James</Name>
  <Image image-view-type="Large" image-color="Black"/>
  <Image image-view-type="Large" image-color="Blue"/>
  <Image image-view-type="small" image-color="Black"/>
  <Image image-view-type="small" image-color="blue"/>
  <DeptCode>456213</DeptCode>
</product>
<product product-id="321">
  <Name>William</Name>
  <Image image-view-type="Large" image-color="White"/>
  <Image image-view-type="Large" image-color="Yellow"/>
  <Image image-view-type="small" image-color="White"/>
  <Image image-view-type="small" image-color="Yellow"/>
 <DeptCode>555555</DeptCode>
</product>
<xsl:key name="prodId" match="row" use="aaa" />
<xsl:for-each select="row[generate-id() =
        generate-id(key('prodId', aaa)[1])]"> 
<xsl:for-each select="key('prodId', aaa)">


Share : facebook icon twitter icon
xslt: How could I use xslt to create a table with multiple columns and rows?

xslt: How could I use xslt to create a table with multiple columns and rows?


By : Ariez Manthony
Date : March 29 2020, 07:55 AM
To fix the issue you can do How would I take this xml and create a table with a column for each "section" element and then display all the "document" elements in that column using xslt? , This is one possible solution:
code :
<xsl:variable name="vCountRows">
  <xsl:apply-templates select="Documents/Section[1]" mode="findmax" />
</xsl:variable>

<xsl:variable name="vCountCols" select="count(Documents/Section)" />

<xsl:template match="/Documents">
  <table r="{$vCountRows}" s="{$vCountCols}">
    <thead>
      <xsl:call-template name="create-thead" />
    </thead>
    <tbody>
      <xsl:call-template name="create-tr" />
    </tbody>
  </table>
</xsl:template>

<xsl:template name="create-thead">
   <tr>
    <xsl:apply-templates select="Section" />
  </tr>    
</xsl:template>

<xsl:template match="Section">
  <th><xsl:value-of select="SectionName" /></th>
</xsl:template>

<xsl:template name="create-tr">
  <xsl:param name="row" select="1" />

  <tr>
    <xsl:call-template name="create-td">
      <xsl:with-param name="row" select="$row" />
    </xsl:call-template>
  </tr>

  <xsl:if test="$row &lt; $vCountRows">
    <xsl:call-template name="create-tr">
      <xsl:with-param name="row" select="$row + 1" />
    </xsl:call-template>
  </xsl:if>

</xsl:template>

<xsl:template name="create-td">
  <xsl:param name="col" select="1" />
  <xsl:param name="row" select="1" />

  <td>
    <xsl:value-of select="Section[$col]/Document[$row]/FileName" />
  </td>

  <xsl:if test="$col &lt; $vCountCols">
    <xsl:call-template name="create-td">
      <xsl:with-param name="col" select="$col + 1" />
      <xsl:with-param name="row" select="$row" />
    </xsl:call-template>
  </xsl:if>
</xsl:template>

<xsl:template match="Section" mode="findmax">
  <xsl:variable name="c" select="count(Document)" />
  <xsl:variable name="next" select="following-sibling::Section[count(Document) &gt; $c][1]" />

  <xsl:choose>    
    <xsl:when test="$next">
      <xsl:apply-templates select="$next" mode="findmax" />
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$c" />
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
<table>
  <thead>
    <tr>
      <td>Green</td>
      <td>MRO/Refurb</td>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Tier 1 Schedules</td>
      <td>Tier 2 Governance</td>
    </tr>
    <tr>
      <td>Tier 3 Schedules</td>
      <td></td>
    </tr>
    <tr>
      <td>Setback Schedule</td>
      <td></td>
    </tr>
    <tr>
      <td>Tier 2 Governance</td>
      <td></td>
    </tr>
  </tbody>
</table>
How to do this in XSLT without incrementing variables? (Tweaking Xalan to create a global XSLT iterator. Do I have other

How to do this in XSLT without incrementing variables? (Tweaking Xalan to create a global XSLT iterator. Do I have other


By : user3713469
Date : March 29 2020, 07:55 AM
will help you Build the complete XML data structure as you need in Java. Then, do the simple iteration in XSL over prepared XML.
You might save a lot of effort and provide a maintainable solution.
Create Custom XSLT Functions using .NET XSLT Processor

Create Custom XSLT Functions using .NET XSLT Processor


By : Dave
Date : March 29 2020, 07:55 AM
hop of those help? xsl:function is a xsl 2.0 feature. The inbuilt .NET xsl processing is not 2.0 (it is W3C XSL Transformations (XSLT) Version 1.0 Recommendation).
You can use script blocks (via XsltSettings.EnableScript), and you can use methods exposed on external objects (via XsltArgumentList.AddExtensionObject). Or you can use a different (2.0) xslt processor; maybe Saxon.
In XSLT 1.0 how to create a lookup function on XML data embedded in the XSLT using key and document('')?

In XSLT 1.0 how to create a lookup function on XML data embedded in the XSLT using key and document('')?


By : user3626624
Date : March 29 2020, 07:55 AM
wish helps you In XSLT 1.0, the key() function works only in the context of the current document (in XSLT 2.0 it has a third argument, allowing you to select the context). In order to use the key on nodes in another document, you must first switch the context to that document - for example:
XSLT 1.0
code :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:variable name="data.font-metrics.line-height">
    <line-height font-size="11">12</line-height>
    <line-height font-size="12">14</line-height>
    <line-height font-size="13">15</line-height>
    <line-height font-size="14">16</line-height>
    <line-height font-size="15">17</line-height>
    <line-height font-size="16">18</line-height>
    <line-height font-size="17">20</line-height>
    <line-height font-size="18">21</line-height>
</xsl:variable>

<xsl:key name="lookup.font-metrics.line-height" match="line-height" use="@font-size"/>

<xsl:template match="/">
    <xsl:param name="font-size" select="14"/>
    <output>
        <!-- other nodes -->
        <!-- switch context to the stylesheet itself in order to use the key -->
        <xsl:for-each select="document('')">
            <lookup>
                <xsl:value-of select="key('lookup.font-metrics.line-height', $font-size)"/>
            </lookup>
        </xsl:for-each>
        <!-- more nodes -->
    </output>
</xsl:template>

</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<output>
   <lookup>16</lookup>
</output>
Move file XSLT - Create new XSLT

Move file XSLT - Create new XSLT


By : Khari Sponge-Fish Ku
Date : March 29 2020, 07:55 AM
Does that help When I'm doing a convertion with XSLT, I need to put in the output directory, another XSLT file. This XSLT file always have the same code. , If you use
code :
<xsl:result-document href="outputdir/sheet.xsl">
  <xsl:copy-of select="document('sheet.xsl')"/>
</xsl:result-document>
Related Posts Related Posts :
  • WSO2 ESB: XML response in WSO2 REST API call not parsed
  • Add image id to image path based on condition
  • How to test data of an XML file
  • how can i solve "No grammar constraints (DTD or XML Schema) referenced in the document." WARNING
  • Why does XML not display in browser but correctly does in XML Notepad 2007 (Microsoft)?
  • How to output based on the input conditions
  • XML to Fixed width text file formatted details
  • Use parameter value as in select in xslt
  • Counting the number of times an xslt transform is done
  • Trouble using an environment variable's value in VBS
  • HTTP response containing XML book-ended by unexpected characters
  • Trying to retrieve just one node value in xslt
  • Select name of alias of xmlns atribute by xpath
  • Get and set text in a xml field
  • Counting frequency of tags / attributes in XML using XSLT
  • Update nodes via merge without changing node order?
  • Flat to Hierarchical XSLT Transform
  • XSL Selecting A Nested Field (From Shopify XML Output)
  • How do I add a semi colon between text fragments but not at the end of text fragments?
  • Parse XSL Date Format
  • Network protocol structure definitions in machine readable form (xml,json,other?)?
  • invalid byte '?' at position 2 of 2-byte sequence validation/parse error
  • Inserting a node into XML
  • Replace before and after string in vim
  • XML/XSL Table won't populate
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org