This technique can be used to add metadata to incoming source documents.< ?xml:namespace prefix = o />
<![CDATA[ <?xml version="1.0" encoding="UTF-8"?> <mydoc> <title>Introduction</title> <title>Introduction2</title> <title>Bogus</title> </mydoc> ]]> |
<![CDATA[ <?xml version="1.0" encoding="UTF-8"?> <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:book="books.uri" exclude-result-prefixes="book"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="mydoc"> <xsl:apply-templates/> </xsl:template> <xsl:template match="title"> <xsl:value-of select="document('')/*/book:category[@desc=current()]/@code"/> </xsl:template> <book:category code="1" desc="Introduction"/> <book:category code="1" desc="Introduction2"/> <book:category code="2" desc="Bogus"/> </xsl:transform> ]]> |