0
votes
<STEP-ProductInformation ExportTime="2018-01-29 12:45:47" ExportContext="fr_FR" ContextID="defaultcontext" WorkspaceID="Approved" 
UseContextLocale="true">
  <Qualifiers>
    <Qualifier ID="Qualifier root">
      <DimensionPointLink DimensionPointID="Qualifier root"/>
    </Qualifier>
    <Qualifier ID="AllCountries">
       <DimensionPointLink DimensionPointID="AllCountries"/>
    </Qualifier>
    <Qualifier ID="std.lang.all">
      <DimensionPointLink DimensionPointID="std.lang.all"/>
    </Qualifier>
    <Qualifier ID="de">
      <DimensionPointLink DimensionPointID="de"/>
    </Qualifier>
    <Qualifier ID="DE">
      <DimensionPointLink DimensionPointID="DE"/>
    </Qualifier>
    <Qualifier ID="fr">
      <DimensionPointLink DimensionPointID="fr"/>
    </Qualifier>
    <Qualifier ID="FR">
      <DimensionPointLink DimensionPointID="FR"/>
    </Qualifier>
  </Qualifiers>
  <Classifications>
    <Classification ID="Level3_1234" UserTypeID="TEST" ParentID="Level2_1234">
  <Name ContextID="de_DE" QualifierID="de" Changed="true">CHANGE TRANS EXP</Name>      <Name ContextID="fr_FR" QualifierID="de" 
Changed="true">CHANGE TRANS EXP</Name>      <MetaData>

<Value AttributeID="ATTR" ContextID="de_DE" QualifierID="de" Changed="true">TEST</Value>
<Value AttributeID="ATTR" ContextID="de_DE" QualifierID="de" Changed="true">TEST</Value>
      </MetaData>
    </Classification>
   </Classifications>
</STEP-ProductInformation>

I am currently seeking to make the following changes:

In the example XML above, I am looking to

  1. Ignore the "ParentID" value (to be found in the node)
  2. Ignore the "WorkspaceID" value (to be found in the node)
  3. Add another value to each node saying: Translation_Status=UpToDate

I have already been able to exclude the attribute values "Name" and "Value" with "contextID=de_De" by using the the following XSLT:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:template match="@* | node()">
    <xsl:copy>
        <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
</xsl:template>
        <xsl:template match="Name[@ContextID='de_DE']"></xsl:template>
    <xsl:template match="Value[@ContextID='de_DE']"></xsl:template>
</xsl:stylesheet>

Now I would ideally like to add points 1,2 and 3 to this XSLT stylesheet.

Any help would be greatly appreciated!

1
What does "ignore" mean? Do you want to remove the ParentID attribute? Then use the same approach, add an empty template <xsl:template match="Classification/@ParentID"/>. - Martin Honnen
Thanks Martin! I thought it would be something along those lines. I just wasn't sure what the exact syntax would be. I'm assuming that the same goes for "STEP-ProductInformation (point 2) :). Do you also have a solution for point 3? - AlexD
Does Translation_Status=UpToDate indicate you want to add an attribute named Translation_Status with the value UpToDate? What does "each node" mean, do you really want to put such an attribute on all elements in the document? - Martin Honnen
Yes, we have an attribute called Translation_Status, which indeed has a value called UpToDate. Essentially, we want to add this attribute to every Classification (in this case there is only one classification in our XML: ID=Level3_1234). I was thinking we could add it as <Value AttributeID="Translation_Status" ContextID="de_DE" QualifierID="de">UpToDate</Value> below the other attribute "TEST" - AlexD

1 Answers

1
votes

To add a child element named Value to the Classification element(s) you can add a template

<xsl:template match="Classification">
  <xsl:copy>
     <xsl:apply-templates select="@* | node()"/>
     <Value AttributeID="Translation_Status" ContextID="de_DE" QualifierID="de">UpToDate</Value>
  </xsl:copy>
</xsl:template>

to your existing stylesheet.

As already pointed out in a comment, to remove a certain node you add an empty template matching it, so to remove the ParentID attribute on Classification add

<xsl:template match="Classification/@ParentID"/>