cvc-complex-type.2.4.d validation error
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 5
- Joined: Wed Mar 09, 2005 10:55 pm
cvc-complex-type.2.4.d validation error
Post by Andreas Kemkes »
I'm evaluating oXygen and get the following validation error:
cvc-complex-type.2.4.d: Invalid content was found starting with element 'p'. No child element is expected at this point. @see: http://www.w3.org/TR/xmlschema-1/#cvc-complex-type
I'm not entirely clear on what is wrong.
The section of the document that fails to validate is
using the following XML Schema definition
This same combination validates in a competing tool.
My questions are:
(1) Is the other tool too linient?
(2) What can I change to make the file validate in oXygen?
Thank you in advance for your help.
Andreas
cvc-complex-type.2.4.d: Invalid content was found starting with element 'p'. No child element is expected at this point. @see: http://www.w3.org/TR/xmlschema-1/#cvc-complex-type
I'm not entirely clear on what is wrong.
The section of the document that fails to validate is
Code: Select all
<slideText>
<p>....</p>
</slideText>
Code: Select all
<xs:element name="slideText" type="text.type"/>
<xs:complexType name="text.type" mixed="true">
<xs:complexContent>
<xs:restriction base="xhtml:Flow"/>
</xs:complexContent>
</xs:complexType>
My questions are:
(1) Is the other tool too linient?
(2) What can I change to make the file validate in oXygen?
Thank you in advance for your help.
Andreas
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi Andreas,
I cannot say exactly what is wrong based only on these fragments. Anyway a guess is that you need to enter p from the xhtml namespace while in your instance document you have p from the same namespace as your slideText element.
From:
<slideText>
<p>....</p>
</slideText>
both p and slideText are in the default namepspace for your document as they have no prefix.
From:
<xs:element name="slideText" type="text.type"/>
<xs:complexType name="text.type" mixed="true">
<xs:complexContent>
<xs:restriction base="xhtml:Flow"/>
</xs:complexContent>
</xs:complexType>
the slideText is defined in the current schema target namespace and the content is xhtml:Flow. Now assumming the current schema target namespace is different from the xhtml namespace then the problem is my guess above.
If that does not solve your problem please consider posting a more complete example (cut down as much as possible).
Please note that you can also validate with external validators in oXygen 7 like Saxon SA, XSV, LIBXML. MSXML, System.XML, SQC.
Best Regards,
George
I cannot say exactly what is wrong based only on these fragments. Anyway a guess is that you need to enter p from the xhtml namespace while in your instance document you have p from the same namespace as your slideText element.
From:
<slideText>
<p>....</p>
</slideText>
both p and slideText are in the default namepspace for your document as they have no prefix.
From:
<xs:element name="slideText" type="text.type"/>
<xs:complexType name="text.type" mixed="true">
<xs:complexContent>
<xs:restriction base="xhtml:Flow"/>
</xs:complexContent>
</xs:complexType>
the slideText is defined in the current schema target namespace and the content is xhtml:Flow. Now assumming the current schema target namespace is different from the xhtml namespace then the problem is my guess above.
If that does not solve your problem please consider posting a more complete example (cut down as much as possible).
Please note that you can also validate with external validators in oXygen 7 like Saxon SA, XSV, LIBXML. MSXML, System.XML, SQC.
Best Regards,
George
-
- Posts: 5
- Joined: Wed Mar 09, 2005 10:55 pm
Post by Andreas Kemkes »
George:
Thank you. That got me on the right track - I also had to change the <xs:restriction> to a <xs:extension>. Thinking about it, I'm somewhat surprised that the other tool would be so lenient and validate the document.
So now I have
and everything validates, but what I really would like to do is to keep writing
and still only allow xhtml:Flow. Is that even possible? I guess I have to do some more research if and how it is possible to pull that part of XHTML into my namespace. Pointers are very welcome, though. Thanks again.
Regards,
Andreas
Thank you. That got me on the right track - I also had to change the <xs:restriction> to a <xs:extension>. Thinking about it, I'm somewhat surprised that the other tool would be so lenient and validate the document.
So now I have
Code: Select all
<slideText>
<xhtml:p>....</xhtml:p>
</slideText>
Code: Select all
<slideText>
<p>....</p>
</slideText>
Regards,
Andreas
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi Andreas,
If the xhtml elements stay in their namespace then it is not possible to have their namespace changed. You can write for instance:
That is you can declare the xhtml namespace as default namespace.
If the schema for xhtml that you use defines for instance the Flow complex type and the elements that go inside this type in a schema document with an absent targetNamespace then you can include that schema document from your schema and thus have the components inherit the target namespace of your including schema.
The schema with an absent target namespace included from a schema with a target namespace is generally called a chameleon schema.
Best Regards,
George
If the xhtml elements stay in their namespace then it is not possible to have their namespace changed. You can write for instance:
Code: Select all
slideText>
<p xmlns="http://www.w3.org/1999/xhtml">
<font size="10">.....</font>
</p>
</slideText>
If the schema for xhtml that you use defines for instance the Flow complex type and the elements that go inside this type in a schema document with an absent targetNamespace then you can include that schema document from your schema and thus have the components inherit the target namespace of your including schema.
The schema with an absent target namespace included from a schema with a target namespace is generally called a chameleon schema.
Best Regards,
George
-
- Posts: 5
- Joined: Wed Mar 09, 2005 10:55 pm
Post by Andreas Kemkes »
George:
My research last night brought me to the same conclusion. Unfortunately, it seems as if I'm out of luck with XHTML, as all the schemas that I could locate had a target namespace. Modularization seems to go into a different direction. I had considered the xmlns option, but it seemed verbose to me, as there may be many <p/> and other XHTML elements directly wrapped in <slidetext/>-like elements. The original idea was to just take the content of the <slidetext/> elements and place it into a <div/> for rendering. It would be nice, if all that could be validated accordingly. So right now, I'm just going to try prefixing properly, which unfortunately the renderer might need to strip. Thanks again for your help.
Regards,
Andreas
My research last night brought me to the same conclusion. Unfortunately, it seems as if I'm out of luck with XHTML, as all the schemas that I could locate had a target namespace. Modularization seems to go into a different direction. I had considered the xmlns option, but it seemed verbose to me, as there may be many <p/> and other XHTML elements directly wrapped in <slidetext/>-like elements. The original idea was to just take the content of the <slidetext/> elements and place it into a <div/> for rendering. It would be nice, if all that could be validated accordingly. So right now, I'm just going to try prefixing properly, which unfortunately the renderer might need to strip. Thanks again for your help.
Regards,
Andreas
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi Andreas,
From what you said I understand that you do not handle the content of slidetext with an XML aware application, for that it should not matter how the xhtml tags are really written (what prefix is used). If you want to just get the text out of there and if slidetext is in some namespace then you can declare the xhtml namespace as default namespace in slidetext and use a prefix for slidetext namespace:
Another way is to process the content of slidetext and extract it in no namespace, that is removing the namespace from the elements. That can be done with a very simple stylesheet like below:
for instance on the following document
it will give
Note that in the above slidetext is in no namepsace, if you have it in some namespace then your template/@match should be changed to match slidetext from that namespace, something like match="s:slidetext" xmlns:s="...".
Best Regards,
George
From what you said I understand that you do not handle the content of slidetext with an XML aware application, for that it should not matter how the xhtml tags are really written (what prefix is used). If you want to just get the text out of there and if slidetext is in some namespace then you can declare the xhtml namespace as default namespace in slidetext and use a prefix for slidetext namespace:
Code: Select all
<s:slidetext xmlns:s="slidetextNamespacehttp://www.w3.org/1999/xhtml" xmlns="">
<p>...<p>
</s:slidetext>
Code: Select all
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="slideText">
<div>
<xsl:apply-templates mode="copyAndRemoveNS"/>
</div>
</xsl:template>
<xsl:template match="*" mode="copyAndRemoveNS" priority="2">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="node() | @*" mode="copyAndRemoveNS"/>
</xsl:element>
</xsl:template>
<xsl:template match="node() | @*" mode="copyAndRemoveNS">
<xsl:copy>
<xsl:apply-templates select="node() | @*" mode="copyAndRemoveNS"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Code: Select all
<slideText>
<p xmlns="http://www.w3.org/1999/xhtml">
<font size="10">.....</font>
</p>
</slideText>
Code: Select all
<?xml version="1.0" encoding="UTF-16"?>
<div>
<p>
<font size="10">.....</font>
</p>
</div>
Best Regards,
George
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service