XSLT – Comparing preceding-sibling’s elements with current’s node element

Almost correct. <xsl:if test=”preceding-sibling::recurso[1]/unidad != unidad”> </xsl:if> The :: is for axes, not for moving along a path (“making a location step”). In XPath terminology: preceding-sibling::recurso[1]/unidad != unidad ””””””””’ ++++++++++ ++++++ ### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ ‘ = axis name (optional, defaults to “child”) + = node test (required) # = predicate (optional, for filtering) ~ = … Read more

Converting XML elements to XML attributes using XSLT

This should work: <xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:template match=”INVENTORY”> <INVENTORY> <xsl:apply-templates/> </INVENTORY> </xsl:template> <xsl:template match=”ITEM”> <ITEM> <xsl:for-each select=”*”> <xsl:attribute name=”{name()}”> <xsl:value-of select=”text()”/> </xsl:attribute> </xsl:for-each> </ITEM> </xsl:template> </xsl:stylesheet>

What is an empty element?

But since both these parts are optional, it would mean that nothing (as in, absence of characters) matches this production. That may be true, but the wording in the spec on this issue is quite clear. There are even examples for empty elements in the next paragraph. <IMG align=”left” src=”http://www.w3.org/Icons/WWW/w3c_home” /> <br></br> <br/> So the … Read more

IIS7 URL Rewrite – Add “www” prefix

To make it more generic you can use following URL Rewrite rule which working for any domain: <?xml version=”1.0″ encoding=”UTF-8″?> <configuration> <system.webServer> <rewrite> <rules> <rule name=”Add WWW” stopProcessing=”true”> <match url=”^(.*)$” /> <conditions> <add input=”{HTTP_HOST}” pattern=”^(?!www\.)(.*)$” /> </conditions> <action type=”Redirect” url=”http://www.{C:0}{PATH_INFO}” redirectType=”Permanent” /> </rule> </rules> </rewrite> </system.webServer>

targetNamespace and xmlns without prefix, what is the difference?

targetNamespace is an XML Schema “artifact”; its purpose: to indicate what particular XML namespace the schema file describes. xmlns – because the XML Schema is an XML document, it is then possible to define a default XML namespace for the XML file itself (this is what xmlns attribute does); the implications are multiple: authoring, and … Read more

XSLT Transform XML with Namespaces

You need to provide a namespace prefix in your xslt for the elements you are transforming. For some reason (at least in a Java JAXP parser) you can’t simply declare a default namespace. This worked for me: <xsl:stylesheet version=”1.0″ xmlns:t=”http://www.test.com/” xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xslFormatting=”urn:xslFormatting”> <xsl:output method=”html” indent=”no”/> <xsl:template match=”/t:ArrayOfBrokerage”> <xsl:for-each select=”t:Brokerage”> Test </xsl:for-each> </xsl:template> </xsl:stylesheet> This … Read more