Xsl: for-each is not supported in this context

I have this XSLT document:

<xsl:stylesheet version="1.0" xmlns:mstns="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/MyDocRootElement">
    <xs:schema id="DataSet" targetNamespace="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" >
        <xs:element name="DataSet" msdata:IsDataSet="true">
            <xs:complexType>
                <xs:choice maxOccurs="unbounded">
                    <xs:element name="Somename"> </xs:element>
                    <xs:element name="OtherName">

                    </xs:element>
                    <!-- FOR EACH NOT SUPPORTED? -->
                    <xsl:for-each select="OtherElements/SubElement">
                             <xs:element name="OtherName">

                            </xs:element>
                    </xsl:for-each>
                </xs:choice>
            </xs:complexType>
        </xs:element>
    </xs:schema>
</xsl:template>
</xsl:stylesheet>

I have a validation error saying that for each item in this context is not supported

I assume this has something to do with checking the xs namespace.

Any ideas on how I can do this? (Exclude verification?)

Thanks Alex

+3
source share
3 answers

Update

@alexbf, who presented the problem, stated in a comment that it does not perform any validation, and the error is the result of starting the conversion using XslCompiledTransform (.NET).

, XslCompiledTransform - - VS2008, nxslt.exe.

, - , .


, -, XSLT!

, XSLT- - , XSD- XSLT.

, XSLT XSLT, ...

. XSLT. , XML- (), XSLT, XSLT.

0

, IDE.

XSLT , .

0

:

- XSLT. XSLT , , , . .

< xsl: comment > , XSLT.

< xsl: comment >

, .

0

Source: https://habr.com/ru/post/1747867/


All Articles