<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2004/07/xpath-functions" xmlns:xdt="http://www.w3.org/2004/07/xpath-datatypes" xmlns:xlink="http://www.w3.org/1999/xlink">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">
	<report>
		<!-- <xsl:namespace name="xlink" select="'http://www.w3.org/1999/xlink'"/>-->
		<xsl:apply-templates/>
	</report>
</xsl:template>

<xsl:template match="text()">
	<xsl:analyze-string select="." regex="FILE:\s+([^\.]+\.[a-zA-Z]{{2,4}})\s+TEXT:\s+(.+)$">
		<xsl:matching-substring><doclink><xsl:attribute name="target"><xsl:value-of select="regex-group(1)"/></xsl:attribute> <xsl:value-of select="regex-group(2)"/></doclink></xsl:matching-substring>
		<xsl:non-matching-substring>
			<xsl:analyze-string select="." regex="LINK:\s+TEXT:\s+(.+)$">
				<xsl:matching-substring><xsl:text>
				!!!!! ONVOLLEDIGE LINK  !!!!!</xsl:text></xsl:matching-substring>
				<xsl:non-matching-substring>
					<xsl:analyze-string select="." regex="LINK:\s+$">
						<xsl:matching-substring/>
						<xsl:non-matching-substring>
							<xsl:analyze-string select="." regex="\s+TEXT:\s+(.+)$">
								<xsl:matching-substring/>
								<xsl:non-matching-substring>
									<xsl:value-of select="." />
								</xsl:non-matching-substring>
							</xsl:analyze-string>
						</xsl:non-matching-substring>
					</xsl:analyze-string>
				</xsl:non-matching-substring>
			</xsl:analyze-string>
		</xsl:non-matching-substring>
	</xsl:analyze-string>
</xsl:template>

<xsl:template match="link">
<xsl:copy>
	<xsl:copy-of select="@*"/>
	<xsl:value-of select="replace(following-sibling::text()[1],'\s+TEXT:\s+','')"/>
</xsl:copy>
</xsl:template>
	
</xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2004. Sonic Software Corporation. All rights reserved.
<metaInformation>
<scenarios ><scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" url="test.xml" htmlbaseurl="" outputurl="" processortype="saxon8" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/></scenarios><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/><MapperBlockPosition></MapperBlockPosition></MapperMetaTag>
</metaInformation>
-->