Answered Visual Studio XSLT debugging - default namespace for input?

  • Tuesday, February 12, 2013 10:14 AM
     
     

    I have several XML input documents which all are in the default namespace and which transform as expected using XslCompiledTransform in code. But exactly the same files don't work under the XSLT debugger in Visual Studio. Why is VS-XSLT not using the default namespace of the input document for its XPath expressions? It works if I add an artificial explcit namespace, but that's not an option for all my documents.

    Example:

    <?xml version="1.0" encoding="utf-8" ?>
    <foo>I am the input file</foo>

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="foo">output OK for XslCompiledTransform but with XSLT in VS this does not match</xsl:template>
    </xsl:stylesheet>

    Thanks for your hints.

All Replies

  • Tuesday, February 12, 2013 10:43 AM
     
     Answered

    The sample XML input you have shown does not use any namespaces at all. That way with an XSLT 1.0 processor like XslCompiledTransform a template doing

       match="foo"

    should match your "foo" input element (which is in no namespace). As far as I know the XSLT processor used by VS 2005 and later is XslCompiledTransform so I am not sure why you would get a difference between running XSLT inside VS or with your own .NET code.

    On the other hand if the input used namespace as in e.g.

      <foo xmlns="http://example.com/ns">...</foo>

    then

      match="foo"

    will never match in XSLT 1.0 as supported by XslCompiledTransform.


    MVP Data Platform Development My blog