We have an odd problem, we are tranforming a pretty complicated XML file using several XSLT files, this isnt the issue.
The issue is that IF the XML file is attached to the schema, the transform doesnt work, if we remove the schema declaration it begins to work ok.
Any clues what the probl开发者_StackOverflow社区em would be?
Here is the schema declation
<xs:schema id="play"
targetNamespace="highway"
elementFormDefault="qualified"
xmlns="highway"
xmlns:mstns="highway"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
And we are simply using the following code to link it (Visual Studio Intellisense then kicks in)
<helloElement name="hello" xmlns="highway">
I appreciate this isnt much to go on, not sure what to offer in terms of symptoms, let me know if you need any info.
Many thanks!
The problem is not the schema, the problem is the namespace declaration xmlns="highway"
which your stylesheet(s) need to take into account with e.g.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:hw="highway"
version="1.0">
<xsl:template match="hw:helloElement">
...
</xsl:template>
</xsl:stylesheet>
and so on, anywhere you match or select an element you need to use a prefix.
When you add the schema declaration, you are adding a default namespace to your XML document (xmlns="highway"
) which wasn't there before. This will then affect the interpretation of element references and XPATHs in the XSLT, because all your elements are now no longer <someElement>
, they are <highway:someElement>
. Check out this link for more information.
精彩评论