You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Miki Yun <Mi...@custserv.com> on 2000/08/31 16:30:56 UTC
validation error
This is long..., but I can't be the only one having this problem???
I am using xalan and xerces (with validation) to modify an input xml file
using a stylesheet, but I am getting the following errors. I am sure the
files are correct, because the code worked fine before I upgraded the Xerces
library to the new version that does validation. Also, I used IBM XSL
editor to verify the syntax. I have looked and looked, and I just can't
find what's wrong. I have include all of the components to replicate the
problem. Any help would really be appreciated!!!
Miki
--------------- Errors ------------------------------------------------
XML Parse Error: Line 3 Column 13 Message Document root element
"wesinquiry", must match DOCTYPE root "wesinquiry".
XML Parse Error: Line 9 Column 17 Message The content of element type
"Payment" must match "(CreditCard|BillMe)".
XML Parse Error: Line 10 Column 12 Message The content of element type
"Order" must match "(Payment)".
XML Parse Error: Line 18 Column 16 Message The content of element type
"Address" must match "(Street1,Street2,City,State,Zip)".
XML Parse Error: Line 19 Column 14 Message The content of element type
"Customer" must match "(Keyline|(Name,Address))".
XML Parse Error: Line 21 Column 15 Message The content of element type
"wesinquiry" must match "(Customer,(Show|Order|Renew))".
XML Parse Error: Line 2 Column 27 Message Attribute "xmlns:xsl" must be
declared for element type "xsl:stylesheet".
XML Parse Error: Line 2 Column 74 Message Attribute "version" must be
declared for element type "xsl:stylesheet".
XML Parse Error: Line 2 Column 81 Message Element type "xsl:stylesheet" must
be declared.
..... and more.....
---------------Java code----------------------------------------------
XSLTProcessor processor= null;
processor = XSLTProcessorFactory.getProcessor();
XSLTInputSource xmlID = new XSLTInputSource("order.xml");
XSLTInputSource stylesheetID = new XSLTInputSource("order.xsl");
Document out = new org.apache.xerces.dom.DocumentImpl();
XSLTResultTarget resultTarget = new XSLTResultTarget(out);
processor.process(xmlID, stylesheetID, resultTarget);
.....
----------- DTD ------------------------------------
<!ELEMENT Name (#PCDATA)>
<!ELEMENT Street1 (#PCDATA)>
<!ELEMENT Street2 (#PCDATA)>
<!ELEMENT City (#PCDATA)>
<!ELEMENT State (#PCDATA)>
<!ELEMENT Zip (#PCDATA)>
<!ELEMENT Address (Street1,Street2?,City,State,Zip)>
<!ELEMENT Keyline (#PCDATA)>
<!ELEMENT Customer (Keyline|(Name,Address))>
<!ELEMENT PhoneNumber (#PCDATA)>
<!ELEMENT Order (Payment)>
<!ELEMENT Renew EMPTY>
<!ELEMENT Show EMPTY>
<!ELEMENT BillMe EMPTY>
<!ELEMENT CreditCard EMPTY>
<!ATTLIST CreditCard
Type (Visa|MasterCard|AmericanExpress|DinerClub) #REQUIRED
ExpireDate CDATA #REQUIRED
CardNumber CDATA #REQUIRED
>
<!ELEMENT Payment (CreditCard|BillMe)>
<!ELEMENT wesinquiry (Customer,(Show|Order|Renew))>
<!ATTLIST wesinquiry
magazine CDATA #REQUIRED
>
------------XML----------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wesinquiry SYSTEM "order.dtd">
<wesinquiry magazine="ABC">
<Order>
<Payment>
<CreditCard Type="Visa"
ExpireDate="02/04/2001"
CardNumber="4444333322221111"/>
</Payment>
</Order>
<Customer>
<Name>Mickey Mouse</Name>
<Address>
<Street1>1 Key Hwy.</Street1>
<City>Appleton</City>
<State>NY</State>
<Zip>11111</Zip>
</Address>
</Customer>
</wesinquiry>
------------ XSL ------------------------------------
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
version="1.0" >
<xsl:template match="wesinquiry">
<WESInquiry>
<MSRSMAG><xsl:value-of select="@magazine"/></MSRSMAG>
<WESDISPLAYSTRATEGY>XML</WESDISPLAYSTRATEGY>
<WESCLEARFIELDS>MWERRCOD,MWERRMSG</WESCLEARFIELDS>
<xsl:apply-templates/>
</WESInquiry>
</xsl:template>
<xsl:template match="Show">
<TRANSTYPE>Show</TRANSTYPE>
</xsl:template>
<xsl:template match="Order">
<TRANSTYPE>Order</TRANSTYPE>
<MSDRC2>F</MSDRC2>
<MSCCANRC>S</MSCCANRC>
<MSCEKX>TDOTWES</MSCEKX>
<MSCTERM>12</MSCTERM>
<xsl:if test="BillMe">
<xsl:apply-templates select="//BillMe"/>
</xsl:if>
<xsl:if test="Payment/CreditCard">
<xsl:apply-templates select="//CreditCard"/>
</xsl:if>
</xsl:template>
<xsl:template match="CreditCard">
<xsl:choose>
<xsl:when test="@Type='Visa'">
<WESBILLTYPE>V</WESBILLTYPE>
</xsl:when>
<xsl:when test="@Type='AmericanExpress'">
<WESBILLTYPE>A</WESBILLTYPE>
</xsl:when>
<xsl:when test="@Type='Discover'">
<WESBILLTYPE>S</WESBILLTYPE>
</xsl:when>
<xsl:when test="@Type='DinersClub'">
<WESBILLTYPE>D</WESBILLTYPE>
</xsl:when>
<xsl:when test="@Type='MasterCard'">
<WESBILLTYPE>M</WESBILLTYPE>
</xsl:when>
</xsl:choose>
<MSCCRDNR><xsl:value-of select="@CardNumber"/></MSCCRDNR>
<WESEXPMM><xsl:value-of
select="substring(@ExpireDate,1,2)"/></WESEXPMM>
<WESEXPDD><xsl:value-of
select="substring(@ExpireDate,4,2)"/></WESEXPDD>
<WESEXPYY><xsl:value-of
select="substring(@ExpireDate,7,4)"/></WESEXPYY>
</xsl:template>
<xsl:template match="Phone">
<MSRRPHON><xsl:value-of select="."/></MSRRPHON>
</xsl:template>
<xsl:template match="EMail">
<MSREMAIL><xsl:value-of select="."/></MSREMAIL>
</xsl:template>
<xsl:template match="BillMe">
<WESBILLTYPE>Z</WESBILLTYPE>
</xsl:template>
<xsl:template match="DisplayType">
<WESDISPLAYSTRATEGY><xsl:value-of select="."/></WESDISPLAYSTRATEGY>
</xsl:template>
<xsl:template match="Keyline">
<WESKEYLINE><xsl:value-of select="."/></WESKEYLINE>
</xsl:template>
<xsl:template match="StatePage">
<WESSTATEPAGE><xsl:value-of select="."/></WESSTATEPAGE>
</xsl:template>
<xsl:template match="Magazine">
<MSRSMAG><xsl:value-of select="."/></MSRSMAG>
</xsl:template>
<xsl:template match="Name">
<MSRSUBNM><xsl:value-of select="."/></MSRSUBNM>
</xsl:template>
<xsl:template match="Street1">
<MSRADDR1><xsl:value-of select="."/></MSRADDR1>
</xsl:template>
<xsl:template match="Street2">
<MSRADDR2><xsl:value-of select="."/></MSRADDR2>
</xsl:template>
<xsl:template match="City">
<WESCITY><xsl:value-of select="."/></WESCITY>
</xsl:template>
<xsl:template match="State">
<WESSTATE><xsl:value-of select="."/></WESSTATE>
</xsl:template>
<xsl:template match="Zip">
<WESZIP><xsl:value-of select="."/></WESZIP>
</xsl:template>
</xsl:stylesheet>
-------------------- Output from IBM XSL Editor ------------------------
<WESInquiry><MSRSMAG>ABC</MSRSMAG><WESDISPLAYSTRATEGY>XML</WESDISPLAYSTRATEG
Y><WESCLEARFIELDS>MWERRCOD,MWERRMSG</WESCLEARFIELDS>
<TRANSTYPE>Order</TRANSTYPE><MSDRC2>F</MSDRC2><MSCCANRC>S</MSCCANRC><MSCEKX>
TDOTWES</MSCEKX><MSCTERM>12</MSCTERM><WESBILLTYPE>V</WESBILLTYPE><MSCCRDNR>4
444333322221111</MSCCRDNR><WESEXPMM>02</WESEXPMM><WESEXPDD>04</WESEXPDD><WES
EXPYY>2001</WESEXPYY>
<MSRSUBNM>Mickey Mouse</MSRSUBNM>
<MSRADDR1>1 Key Hwy.</MSRADDR1>
<WESCITY>Appleton</WESCITY>
<WESSTATE>NY</WESSTATE>
<WESZIP>11111</WESZIP>
</WESInquiry>
Thanks,
Miki