can you please help me with the following problem. I need to convert the value(name) of the fields
simpleType & element in upper case.
I just need the Name of the specific Fields in upperCase.
This is my input XSD
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xsd:simpleType name="ID">
<xsd:annotation>
<xsd:documentation>Datatype string Length 18</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="18"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="AccountId">
<xsd:annotation>
<xsd:documentation>Datatype string Length 18</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="18"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="AssignedToQueueDateTime_c">
<xsd:annotation>
<xsd:documentation>Datatype string Length 28</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="28"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="dataTable">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="dataRow" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ID" nillable="true" minOccurs="0" type="ID"/>
<xsd:element name="AccountId" nillable="true" minOccurs="0" type="AccountId"/>
<xsd:element name="AssignedToQueueDateTime_c" nillable="true" minOccurs="0" type="AssignedToQueueDateTime_c"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
The Output XSD should be :
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xsd:simpleType name="ID">
<xsd:annotation>
<xsd:documentation>Datatype string Length 18</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="18"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ACCOUNTID">
<xsd:annotation>
<xsd:documentation>Datatype string Length 18</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="18"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ASSIGNEDTOQUEUEDATETIME_C">
<xsd:annotation>
<xsd:documentation>Datatype string Length 28</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="28"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="dataTable">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="dataRow" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ID" nillable="true" minOccurs="0" type="ID"/>
<xsd:element name="ACCOUNTID" nillable="true" minOccurs="0" type="ACCOUNTID"/>
<xsd:element name="ASSIGNEDTOQUEUEDATETIME_C" nillable="true" minOccurs="0" type="ASSIGNEDTOQUEUEDATETIME_C"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Do you have a XSLT Mapping for me ? I would be very thankful!
lowercase to uppercase for specific field in XSD
EDIT
This is what i tried.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:variable name="smallCase" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="upperCase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="node()[not(@lang)]/text()">
<xsl:value-of select="translate(., $smallCase, $upperCase)"/>
</xsl:template>
</xsl:stylesheet>
CodePudding user response:
Try it this way:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="smallCase" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="upperCase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xsd:simpleType/@name | xsd:element/@name">
<xsl:attribute name="name">
<xsl:value-of select="translate(., $smallCase, $upperCase)"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>