src-resolve: Cannot resolve the name 'PkReportsTo' to a(n) 'identity constraint' component. [XSD] - xsd-1.1

I was trying to create FK and PK in the XML schema, but it is showing an error in the featured code above. Is shows the message: src-resolve: Cannot resolve the name 'PkReportsTo' to a(n) 'identity constraint' component. [XSD]
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.ricardoterra.com.br"
elementFormDefault="qualified">
<xs:element name="employees">
<xs:complexType>
<xs:sequence>
<xs:element name="employee" maxOccurs="unbounded">
<xs:complexType>
<xs:all>
<xs:element name="firstName" type="xs:string"></xs:element>
<xs:element name="lastName" type="xs:string"></xs:element>
<xs:element name="extension">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="([x][1-9])\w+"></xs:pattern>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="email">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="([a-z])\w+(#)([a-z])\w+(.[a-z]+)*"></xs:pattern>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="officeCode" type="xs:string"></xs:element>
<xs:element name="jobTitle" type="xs:string"></xs:element>
<xs:element name="reportsTo" type="xs:integer" minOccurs="0">
</xs:element>
</xs:all>
<xs:attribute name="number" type="xs:integer"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="number">
<xs:selector xpath="employee"></xs:selector>
<xs:field xpath="#number"></xs:field>
</xs:unique>
<xs:key name="PkEmploye">
<xs:selector xpath="employee"/>
<xs:field xpath="#number"></xs:field>
</xs:key>
<xs:key name="PkReportsTo">
<xs:selector xpath="employee/reportsTo"></xs:selector>
<xs:field xpath="."></xs:field>
</xs:key>
<xs:keyref name="FKtoReportsToEmployee" refer="PkReportsTo">
<xs:selector xpath="employee"></xs:selector>
<xs:field xpath="#number"></xs:field>
</xs:keyref>
</xs:element>
</xs:schema>
I am with a error at the part of my code:
<xs:keyref name="FKtoReportsToEmployee" refer="PkReportsTo">
<xs:selector xpath="employee"></xs:selector>
<xs:field xpath="#number"></xs:field>
</xs:keyref>
I don't know why.

I think you want the target namespace of the schema to be http://www.ricardoterra.com.br so use
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.ricardoterra.com.br"
targetNamespace="http://www.ricardoterra.com.br"
elementFormDefault="qualified">
and that error is likely to go away.

Related

Where is the schema of `child-resources` specified?

I'm trying to find where the schema of the result of a child-resources query is specified in the xsd. It's clearly not a primitiveContent (specified in responsePrimitive) because that doesn't contain the named child-resources arrays.
I think this is in the CDT-responsePrimitive-v.xsd file. In Resourcewrapper you have "m2m:sg_regularResource":
<xs:complexType name="resourceWrapper">
<xs:sequence>
<xs:choice minOccurs="1" maxOccurs="1">
...
<xs:element ref="m2m:sg_regularResource" />
...
</xs:choice>
<xs:element name="URI" type="xs:anyURI" />
</xs:sequence>
</xs:complexType>
In any of the resources that is a "m2m:sg_regularResource" you can find a section like this that allows for "included" child resources:
...
<!-- Child Resources -->
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="childResource" type="m2m:childResourceRef" minOccurs="1" maxOccurs="unbounded" />
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:element ref="m2m:aResourceType" />
<xs:element ref="m2m:anotherResourceType" />
</xs:choice>
</xs:choice>
...

Using namespaces in Oracle XMLTable query returns no results (works without them)

Querying a very large set of XML data in Oracle 11g (datafeeds, 65k rows), and I need to match against existing users in a table with ~240k records. We store the XML data in a binary XML column and use an xmltable() query, and we've registered a schema that is valid and that the XML data we're sending validates against (from within Oracle).
For testing purposes, I'm using a dozen records and executing just the subset query:
select dfids.*
from gsu.datafeed_xmldata gdfxml,
xmltable('/UserIdentifications/OrgIds/OrgId'
passing gdfxml.xml_data_binary
columns LEGAL_ORG_ID varchar2(32) path 'LegalOrg',
LOCAL_ID varchar2(32) path 'LocalId') dfids
This query returns the dozen records quickly, with no problem. The 65k records take about 16 minutes. So we wrote this:
select dfids.*
from gsu.datafeed_xmldata gdfxml,
xmltable(xmlnamespaces('http://xmlns.te.com/infosec/useridentifications_binary3.xsd' as "ids"),
'/ids:UserIdentifications/ids:OrgIds/ids:OrgId'
passing gdfxml.xml_data_binary
columns LEGAL_ORG_ID varchar2(32) path 'ids:LegalOrg',
LOCAL_ID varchar2(32) path 'ids:LocalId') dfids
We now get 0 records. All variations of the paths and columns, with prefixes and without, with different prefixes, using the schema URL, using the qualified schema URL, re-registering the schema, recreating the table... nothing works. It's been three days of digging through a landfill of slightly related answers and solutions, none of which helped. I feel like this should be a simple answer - what am I doing wrong?
Technical Details
Table that holds the xml data:
create table xxx.DATAFEED_XMLDATA
(
xml_data_binary SYS.XMLTYPE
)
xmltype xml_data_binary store as binary xml
tablespace xxx_DATA_A
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 32M
next 4M
minextents 1
maxextents unlimited
);
A minimal set of xml records (there are three ways of uniquely identifying a user – don't ask, it's a sore subject):
<?xml version="1.0" encoding="utf-8"?>
<UserIdentifications>
<UserIds>
<UserId>
<Id>ABC12345</Id>
</UserId>
<UserId>
<Id>DEF67890</Id>
</UserId>
</UserIds>
<PerNrs>
<PerNr>
<Id>00987654</Id>
</PerNr>
<PerNr>
<Id>00341256</Id>
</PerNr>
</PerNrs>
<OrgIds>
<OrgId>
<LegalOrg>0420</LegalOrg>
<LocalId>11432</LocalId>
</OrgId>
<OrgId>
<LegalOrg>0619</LegalOrg>
<LocalId>334266</LocalId>
</OrgId>
</OrgIds>
</UserIdentifications>
Schema details:
select *
from sys.user_xml_schemas;
http://xmlns.te.com/infosec/useridentifications_binary3.xsd
http://xmlns.oracle.com/xdb/schemas/xxx/xmlns.te.com/infosec/useridentifications_binary3.xsd (qualified)
local = yes
hier_type = contents
binary = yes
The schema itself (as registered, pulled from the above query):
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:oraxdb="http://xmlns.oracle.com/xdb"
id="UserIdentificationsSchema" oraxdb:flags="2122017"
oraxdb:schemaURL="http://xmlns.te.com/infosec/useridentifications_binary3.xsd"
oraxdb:schemaOwner="GSU_SOURCE" oraxdb:numProps="11"
xmlns:csx="http://xmlns.oracle.com/2004/CSX">
<xs:element name="UserIdentifications"
xmlns:csx="http://xmlns.oracle.com/2004/CSX"
csx:propertyID="2831" oraxdb:global="true" oraxdb:memType="258">
<xs:complexType>
<xs:annotation>
<xs:appinfo>
<csx:kidList xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb">
<csx:kid csx:propertyID="2823" kidNum="1"></csx:kid>
<csx:kid csx:propertyID="2826" kidNum="2"></csx:kid>
<csx:kid csx:propertyID="2830" kidNum="3"></csx:kid>
</csx:kidList>
</xs:appinfo>
</xs:annotation>
<xs:all minOccurs="0" maxOccurs="1">
<xs:element name="UserIds" csx:propertyID="2823"
oraxdb:global="false" oraxdb:memType="258"
oraxdb:MemInline="false" oraxdb:SQLInline="true"
oraxdb:JavaInline="false">
<xs:complexType>
<xs:annotation>
<xs:appinfo>
<csx:kidList xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb">
<csx:kid csx:propertyID="2822" kidNum="1">
</csx:kid>
</csx:kidList>
</xs:appinfo>
</xs:annotation>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="UserId" csx:propertyID="2822"
oraxdb:global="false" oraxdb:memType="258"
oraxdb:MemInline="false" oraxdb:SQLInline="true"
oraxdb:JavaInline="false">
<xs:complexType>
<xs:annotation>
<xs:appinfo>
<csx:kidList xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb">
<csx:kid csx:propertyID="2821" kidNum="1">
</csx:kid>
</csx:kidList>
</xs:appinfo>
</xs:annotation>
<xs:all>
<xs:element name="Id" csx:propertyID="2821"
oraxdb:global="false" csx:encodingType="string"
oraxdb:memType="1" oraxdb:MemInline="true"
oraxdb:SQLInline="true"
oraxdb:JavaInline="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="collapse">
</xs:whiteSpace>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="PerNrs" csx:propertyID="2826"
oraxdb:global="false" oraxdb:memType="258"
oraxdb:MemInline="false" oraxdb:SQLInline="true"
oraxdb:JavaInline="false">
<xs:complexType>
<xs:annotation>
<xs:appinfo>
<csx:kidList xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb">
<csx:kid csx:propertyID="2825" kidNum="1">
</csx:kid>
</csx:kidList>
</xs:appinfo>
</xs:annotation>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="PerNr" csx:propertyID="2825"
oraxdb:global="false" oraxdb:memType="258"
oraxdb:MemInline="false" oraxdb:SQLInline="true"
oraxdb:JavaInline="false">
<xs:complexType>
<xs:annotation>
<xs:appinfo>
<csx:kidList xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb">
<csx:kid csx:propertyID="2824" kidNum="1">
</csx:kid>
</csx:kidList>
</xs:appinfo>
</xs:annotation>
<xs:all>
<xs:element name="Id" csx:propertyID="2824"
oraxdb:global="false" csx:encodingType="string"
oraxdb:memType="1" oraxdb:MemInline="true"
oraxdb:SQLInline="true"
oraxdb:JavaInline="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="collapse">
</xs:whiteSpace>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="OrgIds" csx:propertyID="2830"
oraxdb:global="false" oraxdb:memType="258"
oraxdb:MemInline="false" oraxdb:SQLInline="true"
oraxdb:JavaInline="false">
<xs:complexType>
<xs:annotation>
<xs:appinfo>
<csx:kidList xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb">
<csx:kid csx:propertyID="2829" kidNum="1">
</csx:kid>
</csx:kidList>
</xs:appinfo>
</xs:annotation>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="OrgId" csx:propertyID="2829"
oraxdb:global="false" oraxdb:memType="258"
oraxdb:MemInline="false" oraxdb:SQLInline="true"
oraxdb:JavaInline="false">
<xs:complexType>
<xs:annotation>
<xs:appinfo>
<csx:kidList xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb">
<csx:kid csx:propertyID="2827" kidNum="1">
</csx:kid>
<csx:kid csx:propertyID="2828" kidNum="2">
</csx:kid>
</csx:kidList>
</xs:appinfo>
</xs:annotation>
<xs:all>
<xs:element name="LegalOrg"
csx:propertyID="2827" oraxdb:global="false"
csx:encodingType="string" oraxdb:memType="1"
oraxdb:MemInline="true" oraxdb:SQLInline="true"
oraxdb:JavaInline="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="collapse">
</xs:whiteSpace>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="LocalId"
csx:propertyID="2828" oraxdb:global="false"
csx:encodingType="string" oraxdb:memType="1"
oraxdb:MemInline="true" oraxdb:SQLInline="true"
oraxdb:JavaInline="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="collapse">
</xs:whiteSpace>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>

Fully Qualified Xpath returns null

<Trial1Response xmlns="http://schemas.microsoft.com/Sql/2008/05/Procedures/dbo">
<Trial1Result>
<DataSet xmlns="http://schemas.datacontract.org/2004/07/System.Data">
<xs:schema id="NewDataSet" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element msdata:IsDataSet="true" name="NewDataSet">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="NewTable">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="cust_id" type="xs:int">
</xs:element>
<xs:element minOccurs="0" name="fname" type="xs:string">
</xs:element>
<xs:element minOccurs="0" name="lname" type="xs:string">
</xs:element>
<xs:element minOccurs="0" name="addr" type="xs:string">
</xs:element>
<xs:element minOccurs="0" name="city" type="xs:string">
</xs:element>
<xs:element minOccurs="0" name="order_id" type="xs:int">
</xs:element>
<xs:element minOccurs="0" name="amount" type="xs:int">
</xs:element>
<xs:element minOccurs="0" name="particulars" type="xs:string">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<NewTable><cust_id>1</cust_id><fname>Akshay</fname><lname>Jain</lname><addr>Borivali</addr><city>Mumbai</city><order_id>221</order_id><amount>41</amount><particulars>Item B</particulars>
</NewTable>
<NewTable><id>223</id><Akshay1id>682</Akshay1id><amount>345</amount><particulars>Item A</particulars>
</NewTable>
</NewDataSet>
</diffgr:diffgram>
</DataSet>
</Trial1Result>
<ReturnValue>0</ReturnValue>
</Trial1Response>
I want to extract the data between the tags NewDataSet. For this, I am using the following Xpath:
/*[local-name="Trial1Response" and namespace-uri()="http://schemas.microsoft.com/Sql/2008/05/Procedures/dbo"]/*[local-name="Trial1Result" and namespace-uri()="http://schemas.microsoft.com/Sql/2008/05/Procedures/dbo"]/*[local-name="DataSet" and namespace-uri()="http://schemas.datacontract.org/2004/07/System.Data"]/*[local-name="diffgr:diffgram" and namespace-uri()="urn:schemas-microsoft-com:xml-diffgram-v1"]/*[local-name="NewDataSet" and namespace-uri()=""]
I get null as my result. What am I doing wrong?
I am expected to use the fully qualified Xpath because Logic apps do not work without it
Edit: I have edited the XML after comments
Correct your xml.
And change local-name to local-name()
like this
/*[local-name()="Trial1Response" and namespace-uri()="http://schemas.microsoft.com/Sql/2008/05/Procedures/dbo"]/*[local-name()="Trial1Result" and namespace-uri()="http://schemas.microsoft.com/Sql/2008/05/Procedures/dbo"]/*[local-name()="DataSet" and namespace-uri()="http://schemas.datacontract.org/2004/07/System.Data"]/*[local-name()="diffgram" and namespace-uri()="urn:schemas-microsoft-com:xml-diffgram-v1"]/*[local-name()="NewDataSet" and namespace-uri()=""]
note: no need of using namespace-uri() if you have single/unique elements in the xml.

Optional lines in Flatfile in biztalk

I have to flatfiles that i need to convert into UBL using Biztalk.
Everything is fine until I reach the end of the flatfiles.
One of them looks like this
RZ0100120400R;RZ01-00120400;RAZER MAMBA 2012 EL;2;739,77;2013.06.12
RZ0100580100R;RZ01-00580100;RAZER NAGA 2012;1;482,38;2013.06.12
RZ0400590100R;RZ04-00590100;RAZER TIAMAT EXPERT;2;605,3;2013.06.12
TOTA;L FAKTURAVÆRDI;EKSKL. MOMS;;18.667,30;
the other one like this:
382908;382908;Anymode Samsung Gal;4;88,87;2013.06.13
382909;382909;Anymode Samsung Gal;4;88,87;2013.06.13
ANYMODESAMSUN;ANYMODE SAMSU;ANYMODE ANYMODE SAM;4;88,87;2013.06.13
;;;;;
TOTA;L FAKTURAVÆRDI;EKSKL. MOMS;;8.116,31;
If I make a schemas for one the other one won't work. So my question is.
How do I make a schema that can take both of them, without problems??
I just need something to ajust for the empty line in the first example.
I am using Visual Studio Flatfile Wizard.
You could make the record/line in question as well as all of its child field elements optional (Min Occurs = 0).
Sample Schema (tested with both sample flat files provided...):
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://SampleProject.FlatFileSchema1" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://SampleProject.FlatFileSchema1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<schemaEditorExtension:schemaInfo namespaceAlias="b" extensionClass="Microsoft.BizTalk.FlatFileExtension.FlatFileExtension" standardName="Flat File" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" />
<b:schemaInfo standard="Flat File" codepage="65001" default_pad_char=" " pad_char_type="char" count_positions_by_byte="false" parser_optimization="speed" lookahead_depth="3" suppress_empty_nodes="false" generate_empty_nodes="true" allow_early_termination="false" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="false" compile_parse_tables="false" root_reference="Root" />
</xs:appinfo>
</xs:annotation>
<xs:element name="Root">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" child_delimiter_type="hex" child_delimiter="0xD 0xA" child_order="infix" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element minOccurs="0" maxOccurs="unbounded" name="line">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" child_delimiter_type="char" child_delimiter=";" child_order="infix" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element minOccurs="0" name="Child1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Child2" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="2" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Child3" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="3" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Child4" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="4" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Child5" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="5" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Child6" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="6" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Hope that helps!
Best regards
Philipp

case-insensitive key in xsd

I have an XSD embedded into an XML like this:
<Replacements>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Replacements">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="Replace" />
</xs:sequence>
</xs:complexType>
<xs:key name="ReplaceKey">
<xs:selector xpath="./Replace"/>
<xs:field xpath="#old"/>
</xs:key>
</xs:element>
<xs:element name="Replace">
<xs:complexType>
<xs:attribute name="old" type="AnythingButLowerCase" use="required" />
<xs:attribute name="new" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:simpleType name="AnythingButLowerCase">
<xs:restriction base="xs:string">
<xs:pattern value="[^a-z]+"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
<Replace old="A1020____9" new="A1020"/>
<Replace old="a1020____9" new="A1020"/>
</Replacements>
I've used xs:key to define a unique-key on "old" attribute of Replace elements.
my problem is I want this key to be CASE-INSENSITIVE.
I've read so many documents indicating I can use xsd functions like upper-case or translate to solve this, but if I write something like
<xs:field xpath="upper-case(#old)"/>
VS2010 gives me a warning like this:
'upper-case(#old)' is an invalid XPath for selector or field.
What is it I'm doing wrong?
Thanks :)
The correct XPath function is "upper-case", not "upper case". Just add in the hyphen.
OK!
I got that!
Using functions in an xpath for a xs:field is not allowed.
The workaround for what I was seeking is to define a simpleType and put a restriction there not allowing lower-case letters.
Something like this:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<Replacements>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Replacements">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="Replace" />
</xs:sequence>
</xs:complexType>
<xs:key name="ReplaceKey">
<xs:selector xpath="./Replace"/>
<xs:field xpath="#old"/>
</xs:key>
</xs:element>
<xs:element name="Replace">
<xs:complexType>
<xs:attribute name="old" type="AnythingButLowerCase" use="required" />
<xs:attribute name="new" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:simpleType name="AnythingButLowerCase">
<xs:restriction base="xs:string">
<xs:pattern value="[^a-z]+"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
<Replace old="A1020____9" new="A1020"/>
<Replace old="a1020____9" new="A1020"/>
</Replacements>
Now this serves as what I want it to.

Resources