Project

Profile

Help

Support #4889 » Catalog_TO_GBO.xslt

fouad MOUTASSIM, 2021-02-03 19:41

 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:err="http://www.w3.org/2005/xqt-errors"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fwkmapping="http://www.loreal.com/hip/fwk/mapping/FwkMapping"
xmlns:document="http://www.loreal.com/hip/fwk/mapping/Document"
xmlns:property="http://www.loreal.com/hip/fwk/common/Property"
xmlns:header="http://www.loreal.com/hip/fwk/mapping/Header" xmlns:csv="http://www.loreal.com/hip/fwk/xsl/csv"
xmlns:bks="urn:books" xmlns:ns0="http://mycompany.org/bookstore/catalog"
exclude-result-prefixes="csv fn xs xsl">

<xsl:output method="xml" encoding="UTF-8" byte-order-mark="no"
indent="yes" />

<!-- [Template match="/" ] [Start] -->
<xsl:template match="/" priority="9">

<fwkmapping:fwkMappingOut>
<fwkmapping:fwkMapping>
<xsl:copy-of copy-namespaces="no"
select="fwkmapping:fwkMappingIn/fwkmapping:fwkMapping/fwkmapping:header" />

<!-- Parse Document input -->
<xsl:variable name="data">
<xsl:copy-of
select="fn:parse-xml(fwkmapping:fwkMappingIn/fwkmapping:fwkMapping/fwkmapping:mappingData/fwkmapping:document/document:content/document:text)" />
</xsl:variable>

<fwkmapping:mappingData>
<fwkmapping:status>
<xsl:value-of select="'OK'" />
</fwkmapping:status>
<!-- Build output -->
<xsl:variable name="output-content">
<bks:books>
<book>
<xsl:attribute name="id"
select="fn:string($data/ns0:catalog/ns0:book/@id)" />
<author>
<xsl:sequence
select="fn:string($data/ns0:catalog/ns0:book/ns0:author)" />
</author>
<title>
<xsl:sequence select="fn:string($data/ns0:catalog/ns0:book/ns0:title)" />
</title>
<genre>
<xsl:sequence select="fn:string($data/ns0:catalog/ns0:book/ns0:genre)" />
</genre>
<price>
<xsl:sequence
select="xs:float(xs:decimal(fn:string($data/ns0:catalog/ns0:book/ns0:price)))" />
</price>
<pub_date>
<xsl:sequence
select="xs:string(xs:date(fn:string($data/ns0:catalog/ns0:book/ns0:publish_date)))" />
</pub_date>
<review>
<xsl:sequence
select="fn:string($data/ns0:catalog/ns0:book/ns0:description)" />
</review>
</book>
</bks:books>
</xsl:variable>



<fwkmapping:document>
<document:content>
<document:text>
<xsl:value-of select="fn:serialize($output-content)" />
</document:text>
</document:content>
<document:size>
<xsl:value-of select="xs:int(string-length($output-content))" />
</document:size>
</fwkmapping:document>


</fwkmapping:mappingData>
</fwkmapping:fwkMapping>
</fwkmapping:fwkMappingOut>
</xsl:template>
</xsl:stylesheet>
(1-1/4)