content_extractor.xsl 1.32 KB
Newer Older
Gregory's avatar
Gregory committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<?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"    
				xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"     
				exclude-result-prefixes="xs"   
				version="2.0">
	
	<xsl:output omit-xml-declaration="yes"
				encoding="UTF-8">
		<!-- Encodage UTF-8 pour caractères spéciaux (accents...) -->
	</xsl:output> 
	

	
	<!-- -->
	<xsl:template match="/" >
	{
			<xsl:apply-templates select="html"/>

	}	
	</xsl:template>
	
	<!-- Extraction des informations du head -->
	<xsl:template match="head">
Gregory's avatar
Gregory committed
25
		"title" : "<xsl:value-of select="title/text()"/>",
Gregory's avatar
Gregory committed
26 27 28 29 30
		
		"keywords" : [
				<xsl:for-each select="meta[@name='keywords']">
					"<xsl:value-of select="@content"/>"<xsl:if test="position() != last()">,</xsl:if>			
				</xsl:for-each>
Gregory's avatar
Gregory committed
31
		],
Gregory's avatar
Gregory committed
32 33 34 35 36 37 38 39 40 41 42
		<xsl:apply-templates select="meta"/>
	</xsl:template>
	
	<!-- Extraction des informations du body -->
	<xsl:template match="body" />
	
	<xsl:template match="meta[@name='author']">
		"author" : "<xsl:value-of select="@content"/>"		
	</xsl:template>
	
	<xsl:template match="meta[@name='date']">
Gregory's avatar
Gregory committed
43
		"date" : "<xsl:value-of select="@content"/>",		
Gregory's avatar
Gregory committed
44 45 46
	</xsl:template>
	
	<xsl:template match="meta[@name='rights']">
Gregory's avatar
Gregory committed
47
		"rights" : "<xsl:value-of select="@content"/>",	
Gregory's avatar
Gregory committed
48 49 50 51 52
	</xsl:template>
	

				
</xsl:stylesheet>