Asked By dou
07-Jun-07 11:04 AM

We receive cXML documents from trading partners that include xml:lang
attributes. The cXML schema defines these as mandatory and we have no control
over the attribute prefix (xml).
We've got as far as downloading then importing the W3C schema that defines
the "lang" attribute, so we can validate incoming documents. Note that when
we use the "Imports" dialog to define the import, we select the W3C schema
which sets the Namespace and Location fields, then enter "xml" for the Prefix
field. However, when the schema is saved then re-opened the Prefix field is
blank. This may (or may not!) be relevent to the next bit.
We need to map the inbound document to an outbound document (still cXML),
and this involves mapping some of the attributes over. However, the mapper
insists on creating an outbound document in which the "lang" attributes have
the prefix "ns0", and it adds a namespace prefix declaration to the root
node. Perhaps because the Prefix is blank it thinks it must create one, even
though the namespace is the standard http://www.w3.org/XML/1998/namespace.
Rather than include the whole cXML schema, I've created a simple project
which demonstrates the problem.
There is a single schema:
xmlns:xs="http://www.w3.org/2001/XMLSchema">
namespace="http://www.w3.org/XML/1998/namespace" />
which imports the W3C schema, saved as xml.xsd. I've removed all of the
annotation for brevity, but the original can be found at
http://www.w3.org/2005/08/xml.xsd.
xmlns="http://www.w3.org/XML/1998/namespace"
targetNamespace="http://www.w3.org/XML/1998/namespace" xml:lang="en"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
Finally, a map just copies the Description element and lang attribute
contents over:
Version="2" XRange="100" YRange="420" OmitXmlDeclaration="Yes"
TreatElementsAsRecords="No" OptimizeValueMapping="Yes"
GenerateDefaultFixedNodes="Yes" CopyPIs="No" method="xml" xmlVersion="1.0"
indent="yes" IgnoreNamespacesForLinks="Yes">
LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Test']/*[local-name()='Description']"
LinkTo="/*[local-name()='<Schema>']/*[local-name()='Test']/*[local-name()='Description']" Label="" />
LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Test']/*[local-name()='Description']/@*[local-name()='lang']"
LinkTo="/*[local-name()='<Schema>']/*[local-name()='Test']/*[local-name()='Description']/@*[local-name()='lang']" Label="" />
I just wired up a send port to a receive port, and included the above map in
the send port. The sample xml document below, which validates using the above
schema, is submitted:
The output is:
xmlns:ns0="http://www.w3.org/XML/1998/namespace">
which does not validate!
We expected the output to be identical to the input, with the "lang"
attribute having the "xml" prefix.
I can sort of understand why BizTalk includes a prefix declaration in the
output because, if the prefix was anything other than "xml", for example
as that's what we are being sent.
I guess there would be a solution using custom pipeline components, but I'm
keen to pursue a simpler solution first.
Anyone had experience with this? Anyone got a solution?? Thanks in advance
for any suggestions.
--
Doug